#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ enprintf(int, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ threearg(char **);
int fourarg(char *argv[]) {
  if (!strcmp(argv[0], "!"))
    return !threearg(argv + 1);
  enprintf(2, "too many arguments\n");
  return 0;
}


x86 assembly (clang, -O0):
<fourarg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xeb6(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    117a <fourarg+0x4a>
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
call   1030 <threearg@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1192 <fourarg+0x62>
mov    $0x2,%edi
lea    0xe7c(%rip),%rsi
call   1050 <enprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fourarg>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rdi
lea    0xec2(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     115c <fourarg+0x2c>
lea    0xeb4(%rip),%rsi
mov    $0x2,%edi
call   1050 <enprintf@plt>
xor    %eax,%eax
pop    %rbx
ret
add    $0x8,%rbx
mov    %rbx,%rdi
call   1030 <threearg@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"!\00"
@.str.1 = [20 x i8] c"too many arguments\0A\00"
define i32 @fourarg(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
store i8** %0, i8*** %3
%4 = load i8**, i8*** %3
%5 = getelementptr inbounds i8*, i8** %4, i64 0
%6 = load i8*, i8** %5
%7 = call i32 @strcmp(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %1
%10 = load i8**, i8*** %3
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = call i32 @threearg(i8** %11)
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
%15 = zext i1 %14 to i32
store i32 %15, i32* %2
br label %18
16: ; preds = %1
%17 = call i32 @enprintf(i32 2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %18
18: ; preds = %16, %9
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@.str = [2 x i8] c"!\00"
@.str.1 = [20 x i8] c"too many arguments\0A\00"
define i32 @fourarg(i8** %0) {
%2 = load i8*, i8** %0
%3 = tail call i32 @strcmp(i8* dereferenceable(1) %2, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = getelementptr inbounds i8*, i8** %0, i64 1
%7 = tail call i32 @threearg(i8** %6)
%8 = icmp eq i32 %7, 0
%9 = zext i1 %8 to i32
br label %12
10: ; preds = %1
%11 = tail call i32 @enprintf(i32 2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %5
%13 = phi i32 [ 0, %10 ], [ %9, %5 ]
ret i32 %13
}