#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 EXIT_SUCCESS;
int /*<<< orphan*/ execute(char **);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *makestring(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stdin;
int main(void) {
  char *arglist[20 + 1];
  int numargs = 0;
  char argbuf[100];
  while (numargs < 20) {
    printf("Arg[%d]?", numargs);
    if (fgets(argbuf, 100, stdin) == NULL)
      exit(EXIT_SUCCESS);
    else if (*argbuf != '\n')
      arglist[numargs] = makestring(argbuf);
    else {
      if (numargs > 0) {
        arglist[numargs] = NULL;
        execute(arglist);
        while (--numargs)
          free(arglist[numargs]);
        numargs = 0;
      }
    }
    numargs++;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xb4(%rbp)
cmpl   $0x14,-0xb4(%rbp)
jge    1285 <main+0x125>
mov    -0xb4(%rbp),%esi
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
lea    -0x120(%rbp),%rdi
mov    0x2e3f(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    11cd <main+0x6d>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
movsbl -0x120(%rbp),%eax
cmp    $0xa,%eax
je     1200 <main+0xa0>
lea    -0x120(%rbp),%rdi
call   1070 <makestring@plt>
mov    %rax,%rcx
movslq -0xb4(%rbp),%rax
mov    %rcx,-0xb0(%rbp,%rax,8)
ff
jmp    126c <main+0x10c>
cmpl   $0x0,-0xb4(%rbp)
jle    1267 <main+0x107>
movslq -0xb4(%rbp),%rax
movq   $0x0,-0xb0(%rbp,%rax,8)
lea    -0xb0(%rbp),%rdi
call   1050 <execute@plt>
mov    -0xb4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xb4(%rbp)
cmp    $0x0,%eax
je     125d <main+0xfd>
movslq -0xb4(%rbp),%rax
mov    -0xb0(%rbp,%rax,8),%rdi
ff
call   1030 <free@plt>
jmp    122c <main+0xcc>
movl   $0x0,-0xb4(%rbp)
jmp    126c <main+0x10c>
jmp    1271 <main+0x111>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    117c <main+0x1c>
mov    0x2d4c(%rip),%rax
mov    (%rax),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
xor    %ebx,%ebx
lea    0xe86(%rip),%r14
mov    0x2e67(%rip),%r13
lea    0xb0(%rsp),%r12
mov    %rsp,%r15
jmp    11a9 <main+0x49>
xchg   %ax,%ax
mov    %r12,%rdi
call   1070 <makestring@plt>
movslq %ebx,%rcx
mov    %rax,(%rsp,%rcx,8)
lea    0x1(%rbx),%eax
cmp    $0x13,%ebx
mov    %eax,%ebx
jge    1207 <main+0xa7>
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    0x0(%r13),%edx
mov    %r12,%rdi
mov    $0x64,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     1222 <main+0xc2>
cmpb   $0xa,0xb0(%rsp)
0a
jne    1190 <main+0x30>
test   %ebx,%ebx
jle    119f <main+0x3f>
mov    %ebx,%ebp
movq   $0x0,(%rsp,%rbp,8)
mov    %r15,%rdi
call   1050 <execute@plt>
cmp    $0x1,%ebx
je     1203 <main+0xa3>
xchg   %ax,%ax
mov    -0x8(%rsp,%rbp,8),%rdi
call   1030 <free@plt>
add    $0xffffffffffffffff,%rbp
cmp    $0x1,%ebp
jne    11f0 <main+0x90>
xor    %ebx,%ebx
jmp    119f <main+0x3f>
mov    0x2dca(%rip),%rax
mov    (%rax),%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"Arg[%d]?\00"
@stdin = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [21 x i8*]
%3 = alloca i32
%4 = alloca [100 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %51, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 20
br i1 %7, label %8, label %54
8: ; preds = %5
%9 = load i32, i32* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%12 = load i32, i32* @stdin
%13 = call i32* @fgets(i8* %11, i32 100, i32 %12)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %8
%16 = load i32, i32* @EXIT_SUCCESS
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %8
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 10
br i1 %22, label %23, label %29
23: ; preds = %18
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%25 = call i8* @makestring(i8* %24)
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [21 x i8*], [21 x i8*]* %2, i64 0, i64 %27
store i8* %25, i8** %28
br label %50
29: ; preds = %18
%30 = load i32, i32* %3
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %49
32: ; preds = %29
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [21 x i8*], [21 x i8*]* %2, i64 0, i64 %34
store i8* null, i8** %35
%36 = getelementptr inbounds [21 x i8*], [21 x i8*]* %2, i64 0, i64 0
%37 = call i32 @execute(i8** %36)
br label %38
38: ; preds = %42, %32
%39 = load i32, i32* %3
%40 = add nsw i32 %39, -1
store i32 %40, i32* %3
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %38
%43 = load i32, i32* %3
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [21 x i8*], [21 x i8*]* %2, i64 0, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 @free(i8* %46)
br label %38
48: ; preds = %38
store i32 0, i32* %3
br label %49
49: ; preds = %48, %29
br label %50
50: ; preds = %49, %23
br label %51
51: ; preds = %50
%52 = load i32, i32* %3
%53 = add nsw i32 %52, 1
store i32 %53, i32* %3
br label %5
54: ; preds = %5
%55 = load i32, i32* @EXIT_SUCCESS
ret i32 %55
}

LLVM IR (-O2):
@.str = [9 x i8] c"Arg[%d]?\00"
@stdin = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [21 x i8*]
%2 = alloca [100 x i8]
%3 = bitcast [21 x i8*]* %1 to i8*
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [21 x i8*], [21 x i8*]* %1, i64 0, i64 0
br label %6
6: ; preds = %0, %40
%7 = phi i32 [ 0, %0 ], [ %42, %40 ]
%8 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @stdin
%10 = call i32* @fgets(i8* %4, i32 100, i32 %9)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %6
%13 = load i32, i32* @EXIT_SUCCESS
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %6
%16 = load i8, i8* %4
%17 = icmp eq i8 %16, 10
br i1 %17, label %22, label %18
18: ; preds = %15
%19 = call i8* @makestring(i8* %4)
%20 = sext i32 %7 to i64
%21 = getelementptr inbounds [21 x i8*], [21 x i8*]* %1, i64 0, i64 %20
store i8* %19, i8** %21
br label %40
22: ; preds = %15
%23 = icmp sgt i32 %7, 0
br i1 %23, label %24, label %40
24: ; preds = %22
%25 = zext i32 %7 to i64
%26 = getelementptr inbounds [21 x i8*], [21 x i8*]* %1, i64 0, i64 %25
store i8* null, i8** %26
%27 = call i32 @execute(i8** %5)
%28 = icmp eq i32 %7, 1
br i1 %28, label %40, label %29
29: ; preds = %24
%30 = zext i32 %7 to i64
%31 = add nsw i64 %30, -1
br label %32
32: ; preds = %29, %32
%33 = phi i64 [ %31, %29 ], [ %37, %32 ]
%34 = getelementptr inbounds [21 x i8*], [21 x i8*]* %1, i64 0, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 @free(i8* %35)
%37 = add nsw i64 %33, -1
%38 = trunc i64 %37 to i32
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %32
40: ; preds = %32, %24, %18, %22
%41 = phi i32 [ %7, %18 ], [ %7, %22 ], [ 0, %24 ], [ 0, %32 ]
%42 = add nsw i32 %41, 1
%43 = icmp slt i32 %41, 19
br i1 %43, label %6, label %44
44: ; preds = %40
%45 = load i32, i32* @EXIT_SUCCESS
ret i32 %45
}