#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 add_file_to_queue(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ print_usage();
int /*<<< orphan*/ printf(char *, ...);
char *strerror(int /*<<< orphan*/);
int add(int argc, char **argv) {
  int i;
  int num_files = argc - 2;
  if (num_files == 0) {
    printf("We need something here.\n");
    print_usage();
    return 1;
  }
  for (i = 2; i < argc; i++) {
    int error = add_file_to_queue(argv[i]);
    if (error) {
      printf("ERROR (mkdir) on line %d: %s\n", 20, strerror(errno));
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    1183 <add+0x43>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <print_usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fe <add+0xbe>
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f7 <add+0xb7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <add_file_to_queue@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11e4 <add+0xa4>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %rax,%rdx
lea    0xe4d(%rip),%rdi
mov    $0x14,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fe <add+0xbe>
jmp    11e9 <add+0xa9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118a <add+0x4a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1171 <add+0x21>
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <print_usage@plt>
jmp    11cc <add+0x7c>
xor    %r14d,%r14d
cmp    $0x3,%edi
jl     11d2 <add+0x82>
mov    %rsi,%rbx
mov    %edi,%r15d
mov    $0x2,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rbx,%rbp,8),%rdi
call   1070 <add_file_to_queue@plt>
test   %eax,%eax
jne    11a8 <add+0x58>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1190 <add+0x40>
jmp    11d2 <add+0x82>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe43(%rip),%rdi
mov    $0x14,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"We need something here.\0A\00"
@.str.1 = [30 x i8] c"ERROR (mkdir) on line %d: %s\0A\00"
@errno = global i32 0
define i32 @add(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = sub nsw i32 %9, 2
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (...) @print_usage()
store i32 1, i32* %3
br label %39
16: ; preds = %2
store i32 2, i32* %6
br label %17
17: ; preds = %35, %16
%18 = load i32, i32* %6
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %38
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 @add_file_to_queue(i8* %26)
store i32 %27, i32* %8
%28 = load i32, i32* %8
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %21
%31 = load i32, i32* @errno
%32 = call i8* @strerror(i32 %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 20, i8* %32)
store i32 1, i32* %3
br label %39
34: ; preds = %21
br label %35
35: ; preds = %34
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %17
38: ; preds = %17
store i32 0, i32* %3
br label %39
39: ; preds = %38, %30, %13
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str.1 = [30 x i8] c"ERROR (mkdir) on line %d: %s\0A\00"
@errno = global i32 0
@str = [24 x i8] c"We need something here.\00"
define i32 @add(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = icmp sgt i32 %0, 2
br i1 %5, label %6, label %24
6: ; preds = %4
%7 = zext i32 %0 to i64
br label %13
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 (...) @print_usage()
br label %24
11: ; preds = %13
%12 = icmp eq i64 %19, %7
br i1 %12, label %24, label %13
13: ; preds = %6, %11
%14 = phi i64 [ 2, %6 ], [ %19, %11 ]
%15 = getelementptr inbounds i8*, i8** %1, i64 %14
%16 = load i8*, i8** %15
%17 = tail call i32 @add_file_to_queue(i8* %16)
%18 = icmp eq i32 %17, 0
%19 = add nuw nsw i64 %14, 1
br i1 %18, label %11, label %20
20: ; preds = %13
%21 = load i32, i32* @errno
%22 = tail call i8* @strerror(i32 %21)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 20, i8* %22)
br label %24
24: ; preds = %11, %4, %20, %8
%25 = phi i32 [ 1, %8 ], [ 1, %20 ], [ 0, %4 ], [ 0, %11 ]
ret i32 %25
}