semctl: fix indirect syscall decoding

On architectures where the semctl call is implemented by the ipc syscall
the 4th argument is passed by reference.

* ipc.c (sys_semctl): Handle the indirect ipc subcall case.
* tests/ipc_sem.c (main): Optionally match indirection
in the 4th argument of semctl calls.

Reported-by: Andreas Schwab <schwab@suse.de>
diff --git a/ipc.c b/ipc.c
index 4387772..a94f572 100644
--- a/ipc.c
+++ b/ipc.c
@@ -281,7 +281,16 @@
 	if (entering(tcp)) {
 		tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
 		PRINTCTL(semctl_flags, tcp->u_arg[2], "SEM_???");
-		tprintf(", %#lx", tcp->u_arg[3]);
+		tprints(", ");
+		if (indirect_ipccall(tcp)) {
+			if (current_wordsize == sizeof(int)) {
+				printnum_int(tcp, tcp->u_arg[3], "%#x");
+			} else {
+				printnum_long(tcp, tcp->u_arg[3], "%#lx");
+			}
+		} else {
+			tprintf("%#lx", tcp->u_arg[3]);
+		}
 	}
 	return 0;
 }