#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*/ gets(char *);
int /*<<< orphan*/ printCommands();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ runCommand(int, char **);
int sscanf(char *, char *, char *, char *, char *);
int main(void) {
  char line[80];
  char tokens[3][40];
  printCommands();
  while (1) {
    printf("> ");
    gets(line);
    *tokens[0] = '\0';
    *tokens[1] = '\0';
    *tokens[2] = '\0';
    int tokensCount =
        sscanf(line, "%39s %39s %39s", tokens[0], tokens[1], tokens[2]);
    runCommand(tokensCount, tokens);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <printCommands@plt>
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1060 <gets@plt>
movb   $0x0,-0xe0(%rbp)
movb   $0x0,-0xb8(%rbp)
movb   $0x0,-0x90(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0xe0(%rbp),%rdx
lea    -0xe0(%rbp),%rcx
add    $0x28,%rcx
mov    %rcx,-0xf8(%rbp)
lea    -0xe0(%rbp),%r8
add    $0x50,%r8
mov    %r8,-0xf0(%rbp)
lea    0xe3a(%rip),%rsi
call   1070 <sscanf@plt>
mov    %eax,-0xe4(%rbp)
mov    -0xe4(%rbp),%edi
lea    -0xe0(%rbp),%rsi
call   1050 <runCommand@plt>
jmp    1169 <main+0x19>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
xor    %eax,%eax
call   1040 <printCommands@plt>
lea    0x28(%rsp),%r14
lea    0x50(%rsp),%r15
lea    0xe87(%rip),%r12
lea    0x80(%rsp),%rbx
lea    0xe7b(%rip),%r13
mov    %rsp,%rbp
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1060 <gets@plt>
movb   $0x0,(%rsp)
movb   $0x0,0x28(%rsp)
movb   $0x0,0x50(%rsp)
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %r14,%rcx
mov    %r15,%r8
call   1070 <sscanf@plt>
mov    %eax,%edi
mov    %rbp,%rsi
call   1050 <runCommand@plt>
jmp    1190 <main+0x40>

LLVM IR (-O0):
@.str = [3 x i8] c"> \00"
@.str.1 = [15 x i8] c"%39s %39s %39s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca [3 x [40 x i8]]
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (...) @printCommands()
br label %6
6: ; preds = %0, %6
%7 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%9 = call i32 @gets(i8* %8)
%10 = getelementptr inbounds [3 x [40 x i8]], [3 x [40 x i8]]* %3, i64 0, i64 0
%11 = getelementptr inbounds [40 x i8], [40 x i8]* %10, i64 0, i64 0
store i8 0, i8* %11
%12 = getelementptr inbounds [3 x [40 x i8]], [3 x [40 x i8]]* %3, i64 0, i64 1
%13 = getelementptr inbounds [40 x i8], [40 x i8]* %12, i64 0, i64 0
store i8 0, i8* %13
%14 = getelementptr inbounds [3 x [40 x i8]], [3 x [40 x i8]]* %3, i64 0, i64 2
%15 = getelementptr inbounds [40 x i8], [40 x i8]* %14, i64 0, i64 0
store i8 0, i8* %15
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%17 = getelementptr inbounds [3 x [40 x i8]], [3 x [40 x i8]]* %3, i64 0, i64 0
%18 = getelementptr inbounds [40 x i8], [40 x i8]* %17, i64 0, i64 0
%19 = getelementptr inbounds [3 x [40 x i8]], [3 x [40 x i8]]* %3, i64 0, i64 1
%20 = getelementptr inbounds [40 x i8], [40 x i8]* %19, i64 0, i64 0
%21 = getelementptr inbounds [3 x [40 x i8]], [3 x [40 x i8]]* %3, i64 0, i64 2
%22 = getelementptr inbounds [40 x i8], [40 x i8]* %21, i64 0, i64 0
%23 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* %20, i8* %22)
store i32 %23, i32* %4
%24 = load i32, i32* %4
%25 = getelementptr inbounds [3 x [40 x i8]], [3 x [40 x i8]]* %3, i64 0, i64 0
%26 = bitcast [40 x i8]* %25 to i8**
%27 = call i32 @runCommand(i32 %24, i8** %26)
br label %6
}

LLVM IR (-O2):
@.str = [3 x i8] c"> \00"
@.str.1 = [15 x i8] c"%39s %39s %39s\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = alloca [3 x [40 x i8]]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [3 x [40 x i8]], [3 x [40 x i8]]* %2, i64 0, i64 0, i64 0
%5 = tail call i32 (...) @printCommands()
%6 = getelementptr inbounds [3 x [40 x i8]], [3 x [40 x i8]]* %2, i64 0, i64 1, i64 0
%7 = getelementptr inbounds [3 x [40 x i8]], [3 x [40 x i8]]* %2, i64 0, i64 2, i64 0
%8 = bitcast [3 x [40 x i8]]* %2 to i8**
br label %9
9: ; preds = %9, %0
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @gets(i8* %3)
store i8 0, i8* %4
store i8 0, i8* %6
store i8 0, i8* %7
%12 = call i32 @sscanf(i8* %3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* %6, i8* %7)
%13 = call i32 @runCommand(i32 %12, i8** %8)
br label %9
}