#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 */
char **debugger_parse_commandline(char const *, int *);
scalar_t__ strcmp(char *, char *);
int test_debugger_commandline() {
  const char *test_data = "5 + 3 \"5 + 3\"";
  int argc = 0;
  char **result = debugger_parse_commandline(test_data, &argc);
  if (argc != 4) {
    return 1;
  }
  if (strcmp(result[0], "5") != 0) {
    return 2;
  }
  if (strcmp(result[1], "+") != 0) {
    return 3;
  }
  if (strcmp(result[2], "3") != 0) {
    return 4;
  }
  if (strcmp(result[3], "5 + 3") != 0) {
    return 5;
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_debugger_commandline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <debugger_parse_commandline@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x4,-0x14(%rbp)
je     1161 <test_debugger_commandline+0x41>
movl   $0x1,-0x4(%rbp)
jmp    120f <test_debugger_commandline+0xef>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
lea    0xe9f(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     118a <test_debugger_commandline+0x6a>
movl   $0x2,-0x4(%rbp)
jmp    120f <test_debugger_commandline+0xef>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe77(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11b4 <test_debugger_commandline+0x94>
movl   $0x3,-0x4(%rbp)
jmp    120f <test_debugger_commandline+0xef>
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe53(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11de <test_debugger_commandline+0xbe>
movl   $0x4,-0x4(%rbp)
jmp    120f <test_debugger_commandline+0xef>
mov    -0x20(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe25(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1208 <test_debugger_commandline+0xe8>
movl   $0x5,-0x4(%rbp)
jmp    120f <test_debugger_commandline+0xef>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_debugger_commandline>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xecc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <debugger_parse_commandline@plt>
mov    %rax,%rbx
mov    $0x1,%eax
cmpl   $0x4,0xc(%rsp)
jne    11be <test_debugger_commandline+0x9e>
mov    (%rbx),%rdi
lea    0xeb7(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
mov    $0x2,%eax
test   %rcx,%rcx
jne    11be <test_debugger_commandline+0x9e>
mov    0x8(%rbx),%rdi
lea    0xe9c(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
mov    $0x3,%eax
test   %rcx,%rcx
jne    11be <test_debugger_commandline+0x9e>
mov    0x10(%rbx),%rdi
lea    0xe85(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
mov    $0x4,%eax
test   %rcx,%rcx
jne    11be <test_debugger_commandline+0x9e>
mov    0x18(%rbx),%rdi
lea    0xe64(%rip),%rsi
call   1030 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    (%rcx,%rcx,4),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"5 + 3 \225 + 3\22\00"
@.str.1 = [2 x i8] c"5\00"
@.str.2 = [2 x i8] c"+\00"
@.str.3 = [2 x i8] c"3\00"
@.str.4 = [6 x i8] c"5 + 3\00"
define i32 @test_debugger_commandline() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8**
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %2
store i32 0, i32* %3
%5 = load i8*, i8** %2
%6 = call i8** @debugger_parse_commandline(i8* %5, i32* %3)
store i8** %6, i8*** %4
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, 4
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 1, i32* %1
br label %39
10: ; preds = %0
%11 = load i8**, i8*** %4
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %10
store i32 2, i32* %1
br label %39
17: ; preds = %10
%18 = load i8**, i8*** %4
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %17
store i32 3, i32* %1
br label %39
24: ; preds = %17
%25 = load i8**, i8*** %4
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %24
store i32 4, i32* %1
br label %39
31: ; preds = %24
%32 = load i8**, i8*** %4
%33 = getelementptr inbounds i8*, i8** %32, i64 3
%34 = load i8*, i8** %33
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %31
store i32 5, i32* %1
br label %39
38: ; preds = %31
store i32 0, i32* %1
br label %39
39: ; preds = %38, %37, %30, %23, %16, %9
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
@.str = [14 x i8] c"5 + 3 \225 + 3\22\00"
@.str.1 = [2 x i8] c"5\00"
@.str.2 = [2 x i8] c"+\00"
@.str.3 = [2 x i8] c"3\00"
@.str.4 = [6 x i8] c"5 + 3\00"
define i32 @test_debugger_commandline() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = call i8** @debugger_parse_commandline(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp eq i32 %4, 4
br i1 %5, label %6, label %26
6: ; preds = %0
%7 = load i8*, i8** %3
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %26
10: ; preds = %6
%11 = getelementptr inbounds i8*, i8** %3, i64 1
%12 = load i8*, i8** %11
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %10
%16 = getelementptr inbounds i8*, i8** %3, i64 2
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %15
%21 = getelementptr inbounds i8*, i8** %3, i64 3
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
%25 = select i1 %24, i32 0, i32 5
br label %26
26: ; preds = %20, %15, %10, %6, %0
%27 = phi i32 [ 1, %0 ], [ 2, %6 ], [ 3, %10 ], [ 4, %15 ], [ %25, %20 ]
ret i32 %27
}