#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *);
void bad_arg(char **arguments, int c, int d, int argcc) {
  int e = 0;
  if (c + 1 == argcc) {
    printf(" not enough args\n");
    while (e < d + 1)
      free(arguments[e++]);
    exit(0);
  }
}


x86 assembly (clang, -O0):
<bad_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cmp    -0x14(%rbp),%eax
jne    119f <bad_arg+0x6f>
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1198 <bad_arg+0x68>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
jmp    1167 <bad_arg+0x37>
xor    %edi,%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bad_arg>:
add    $0x1,%esi
cmp    %ecx,%esi
je     1138 <bad_arg+0x8>
ret
push   %r15
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rdi,%r15
lea    0xeb6(%rip),%rdi
call   1040 <puts@plt>
test   %r14d,%r14d
js     1172 <bad_arg+0x42>
add    $0x1,%r14d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdi
add    $0x1,%rbx
call   1030 <free@plt>
cmp    %rbx,%r14
jne    1160 <bad_arg+0x30>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c" not enough args\0A\00"
define void @bad_arg(i8** %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8** %0, i8*** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
%10 = load i32, i32* %6
%11 = add nsw i32 %10, 1
%12 = load i32, i32* %8
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %31
14: ; preds = %4
%15 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %21, %14
%17 = load i32, i32* %9
%18 = load i32, i32* %7
%19 = add nsw i32 %18, 1
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %29
21: ; preds = %16
%22 = load i8**, i8*** %5
%23 = load i32, i32* %9
%24 = add nsw i32 %23, 1
store i32 %24, i32* %9
%25 = sext i32 %23 to i64
%26 = getelementptr inbounds i8*, i8** %22, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @free(i8* %27)
br label %16
29: ; preds = %16
%30 = call i32 @exit(i32 0)
unreachable
31: ; preds = %4
ret void
}

LLVM IR (-O2):
@str = [17 x i8] c" not enough args\00"
define void @bad_arg(i8** nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = add nsw i32 %1, 1
%6 = icmp eq i32 %5, %3
br i1 %6, label %7, label %22
7: ; preds = %4
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%9 = icmp slt i32 %2, 0
br i1 %9, label %20, label %10
10: ; preds = %7
%11 = add nuw i32 %2, 1
%12 = zext i32 %11 to i64
br label %13
13: ; preds = %10, %13
%14 = phi i64 [ 0, %10 ], [ %15, %13 ]
%15 = add nuw nsw i64 %14, 1
%16 = getelementptr inbounds i8*, i8** %0, i64 %14
%17 = load i8*, i8** %16
%18 = tail call i32 @free(i8* %17)
%19 = icmp eq i64 %15, %12
br i1 %19, label %20, label %13
20: ; preds = %13, %7
%21 = tail call i32 @exit(i32 0)
unreachable
22: ; preds = %4
ret void
}