#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*/ SIGINT;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ execute(char **);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
char *makestring(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int main() {
  char *arglist[20 + 1];
  int numargs = 0;
  char argbuf[100];
  signal(SIGINT, SIG_IGN);
  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);
        numargs = 0;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xb4(%rbp)
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
call   1060 <signal@plt>
cmpl   $0x14,-0xb4(%rbp)
jge    1245 <main+0xf5>
mov    -0xb4(%rbp),%esi
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
lea    -0x120(%rbp),%rdi
mov    0x2e30(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1205 <main+0xb5>
movsbl -0x120(%rbp),%eax
cmp    $0xa,%eax
je     1205 <main+0xb5>
lea    -0x120(%rbp),%rdi
call   1070 <makestring@plt>
mov    %rax,%rcx
mov    -0xb4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xb4(%rbp)
cltq
mov    %rcx,-0xb0(%rbp,%rax,8)
ff
jmp    1240 <main+0xf0>
cmpl   $0x0,-0xb4(%rbp)
jle    123b <main+0xeb>
movslq -0xb4(%rbp),%rax
movq   $0x0,-0xb0(%rbp,%rax,8)
lea    -0xb0(%rbp),%rdi
call   1040 <execute@plt>
movl   $0x0,-0xb4(%rbp)
jmp    1240 <main+0xf0>
jmp    1183 <main+0x33>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x120,%rsp
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
call   1060 <signal@plt>
xor    %ebp,%ebp
lea    0xe81(%rip),%r14
mov    0x2e5a(%rip),%r12
mov    %rsp,%rbx
lea    0x70(%rsp),%r15
jmp    11a8 <main+0x58>
mov    %rbx,%rdi
call   1070 <makestring@plt>
movslq %ebp,%rcx
add    $0x1,%ebp
mov    %rax,0x70(%rsp,%rcx,8)
cmp    $0x14,%ebp
jge    11e9 <main+0x99>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     11ce <main+0x7e>
cmpb   $0xa,(%rsp)
jne    1190 <main+0x40>
test   %ebp,%ebp
jle    11a3 <main+0x53>
mov    %ebp,%eax
movq   $0x0,0x70(%rsp,%rax,8)
mov    %r15,%rdi
call   1040 <execute@plt>
xor    %ebp,%ebp
jmp    11a3 <main+0x53>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SIGINT = global i32 0
@SIG_IGN = global i32 0
@.str = [10 x i8] c"arg[%d]? \00"
@stdin = 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
%5 = load i32, i32* @SIGINT
%6 = load i32, i32* @SIG_IGN
%7 = call i32 @signal(i32 %5, i32 %6)
br label %8
8: ; preds = %40, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 20
br i1 %10, label %11, label %41
11: ; preds = %8
%12 = load i32, i32* %3
%13 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%15 = load i32, i32* @stdin
%16 = call i64 @fgets(i8* %14, i32 100, i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %30
18: ; preds = %11
%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 %30
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 = add nsw i32 %26, 1
store i32 %27, i32* %3
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds [21 x i8*], [21 x i8*]* %2, i64 0, i64 %28
store i8* %25, i8** %29
br label %40
30: ; preds = %18, %11
%31 = load i32, i32* %3
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [21 x i8*], [21 x i8*]* %2, i64 0, i64 %35
store i8* null, i8** %36
%37 = getelementptr inbounds [21 x i8*], [21 x i8*]* %2, i64 0, i64 0
%38 = call i32 @execute(i8** %37)
store i32 0, i32* %3
br label %39
39: ; preds = %33, %30
br label %40
40: ; preds = %39, %23
br label %8
41: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@SIGINT = global i32 0
@SIG_IGN = global i32 0
@.str = [10 x i8] c"arg[%d]? \00"
@stdin = 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 = load i32, i32* @SIGINT
%6 = load i32, i32* @SIG_IGN
%7 = tail call i32 @signal(i32 %5, i32 %6)
%8 = getelementptr inbounds [21 x i8*], [21 x i8*]* %1, i64 0, i64 0
br label %9
9: ; preds = %0, %29
%10 = phi i32 [ 0, %0 ], [ %30, %29 ]
%11 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* @stdin
%13 = call i64 @fgets(i8* %4, i32 100, i32 %12)
%14 = icmp ne i64 %13, 0
%15 = load i8, i8* %4
%16 = icmp ne i8 %15, 10
%17 = select i1 %14, i1 %16, i1 false
br i1 %17, label %18, label %23
18: ; preds = %9
%19 = call i8* @makestring(i8* %4)
%20 = add nsw i32 %10, 1
%21 = sext i32 %10 to i64
%22 = getelementptr inbounds [21 x i8*], [21 x i8*]* %1, i64 0, i64 %21
store i8* %19, i8** %22
br label %29
23: ; preds = %9
%24 = icmp sgt i32 %10, 0
br i1 %24, label %25, label %29
25: ; preds = %23
%26 = zext i32 %10 to i64
%27 = getelementptr inbounds [21 x i8*], [21 x i8*]* %1, i64 0, i64 %26
store i8* null, i8** %27
%28 = call i32 @execute(i8** %8)
br label %29
29: ; preds = %23, %25, %18
%30 = phi i32 [ %20, %18 ], [ 0, %25 ], [ %10, %23 ]
%31 = icmp slt i32 %30, 20
br i1 %31, label %9, label %32
32: ; preds = %29
ret i32 0
}