#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 **);
scalar_t__ 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) && *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    1262 <main+0x112>
mov    -0xb4(%rbp),%esi
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
lea    -0x120(%rbp),%rdi
mov    0x2e4f(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     11e2 <main+0x92>
movsbl -0x120(%rbp),%eax
cmp    $0xa,%eax
je     11e2 <main+0x92>
lea    -0x120(%rbp),%rdi
call   1070 <makestring@plt>
mov    %rax,%rcx
movslq -0xb4(%rbp),%rax
mov    %rcx,-0xb0(%rbp,%rax,8)
ff
jmp    124e <main+0xfe>
cmpl   $0x0,-0xb4(%rbp)
jle    1249 <main+0xf9>
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     123f <main+0xef>
movslq -0xb4(%rbp),%rax
mov    -0xb0(%rbp,%rax,8),%rdi
ff
call   1030 <free@plt>
jmp    120e <main+0xbe>
movl   $0x0,-0xb4(%rbp)
jmp    124e <main+0xfe>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    116c <main+0x1c>
mov    0x2d6f(%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    0xe96(%rip),%r14
mov    0x2e77(%rip),%r13
lea    0xb0(%rsp),%r12
mov    %rsp,%r15
jmp    1199 <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    11f7 <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     11c3 <main+0x73>
cmpb   $0xa,0xb0(%rsp)
0a
jne    1180 <main+0x30>
test   %ebx,%ebx
jle    118f <main+0x3f>
mov    %ebx,%ebp
movq   $0x0,(%rsp,%rbp,8)
mov    %r15,%rdi
call   1050 <execute@plt>
cmp    $0x1,%ebx
je     11f3 <main+0xa3>
xchg   %ax,%ax
mov    -0x8(%rsp,%rbp,8),%rdi
call   1030 <free@plt>
add    $0xffffffffffffffff,%rbp
cmp    $0x1,%ebp
jne    11e0 <main+0x90>
xor    %ebx,%ebx
jmp    118f <main+0x3f>
mov    0x2dda(%rip),%rax
mov    (%rax),%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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 = %47, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 20
br i1 %7, label %8, label %50
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 i64 @fgets(i8* %11, i32 100, i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %8
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 10
br i1 %19, label %20, label %26
20: ; preds = %15
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%22 = call i8* @makestring(i8* %21)
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [21 x i8*], [21 x i8*]* %2, i64 0, i64 %24
store i8* %22, i8** %25
br label %47
26: ; preds = %15, %8
%27 = load i32, i32* %3
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %46
29: ; preds = %26
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [21 x i8*], [21 x i8*]* %2, i64 0, i64 %31
store i8* null, i8** %32
%33 = getelementptr inbounds [21 x i8*], [21 x i8*]* %2, i64 0, i64 0
%34 = call i32 @execute(i8** %33)
br label %35
35: ; preds = %39, %29
%36 = load i32, i32* %3
%37 = add nsw i32 %36, -1
store i32 %37, i32* %3
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %45
39: ; preds = %35
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [21 x i8*], [21 x i8*]* %2, i64 0, i64 %41
%43 = load i8*, i8** %42
%44 = call i32 @free(i8* %43)
br label %35
45: ; preds = %35
store i32 0, i32* %3
br label %46
46: ; preds = %45, %26
br label %47
47: ; preds = %46, %20
%48 = load i32, i32* %3
%49 = add nsw i32 %48, 1
store i32 %49, i32* %3
br label %5
50: ; preds = %5
%51 = load i32, i32* @EXIT_SUCCESS
ret i32 %51
}

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, %37
%7 = phi i32 [ 0, %0 ], [ %39, %37 ]
%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 i64 @fgets(i8* %4, i32 100, i32 %9)
%11 = icmp ne i64 %10, 0
%12 = load i8, i8* %4
%13 = icmp ne i8 %12, 10
%14 = select i1 %11, i1 %13, i1 false
br i1 %14, label %15, label %19
15: ; preds = %6
%16 = call i8* @makestring(i8* %4)
%17 = sext i32 %7 to i64
%18 = getelementptr inbounds [21 x i8*], [21 x i8*]* %1, i64 0, i64 %17
store i8* %16, i8** %18
br label %37
19: ; preds = %6
%20 = icmp sgt i32 %7, 0
br i1 %20, label %21, label %37
21: ; preds = %19
%22 = zext i32 %7 to i64
%23 = getelementptr inbounds [21 x i8*], [21 x i8*]* %1, i64 0, i64 %22
store i8* null, i8** %23
%24 = call i32 @execute(i8** %5)
%25 = icmp eq i32 %7, 1
br i1 %25, label %37, label %26
26: ; preds = %21
%27 = zext i32 %7 to i64
%28 = add nsw i64 %27, -1
br label %29
29: ; preds = %26, %29
%30 = phi i64 [ %28, %26 ], [ %34, %29 ]
%31 = getelementptr inbounds [21 x i8*], [21 x i8*]* %1, i64 0, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 @free(i8* %32)
%34 = add nsw i64 %30, -1
%35 = trunc i64 %34 to i32
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %29
37: ; preds = %29, %21, %19, %15
%38 = phi i32 [ %7, %15 ], [ %7, %19 ], [ 0, %21 ], [ 0, %29 ]
%39 = add nsw i32 %38, 1
%40 = icmp slt i32 %38, 19
br i1 %40, label %6, label %41
41: ; preds = %37
%42 = load i32, i32* @EXIT_SUCCESS
ret i32 %42
}