#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*/ abort();
int /*<<< orphan*/ load_nl_args_buf(char *, int /*<<< orphan*/, int *,
                                    char ***);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strlen(char *);
void test(void) {
  char b[] = "hello\ngoodbye";
  int argc = 0;
  char **argv = NULL;
  load_nl_args_buf(b, strlen(b), &argc, &argv);
  if (argc != 2) {
    abort();
  }
  if (strcmp(argv[0], "hello")) {
    abort();
  }
  if (strcmp(argv[1], "goodbye")) {
    abort();
  }
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xeb1(%rip),%rax
mov    %rax,-0xe(%rbp)
mov    0xeaf(%rip),%eax
mov    %eax,-0x6(%rbp)
mov    0xea9(%rip),%ax
mov    %ax,-0x2(%rbp)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0xe(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0xe(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
lea    -0x14(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1050 <load_nl_args_buf@plt>
cmpl   $0x2,-0x14(%rbp)
je     11ab <test+0x6b>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
lea    0xe55(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11cf <test+0x8f>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe28(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11f4 <test+0xb4>
mov    $0x0,%al
call   1030 <abort@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbx
sub    $0x20,%rsp
movabs $0x657962646f6f67,%rax
mov    %rax,0x16(%rsp)
movabs $0x6f670a6f6c6c6568,%rax
0a 67 6f
mov    %rax,0x10(%rsp)
movl   $0x0,0x4(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x4(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <load_nl_args_buf@plt>
cmpl   $0x2,0x4(%rsp)
jne    11d5 <test+0x95>
mov    0x8(%rsp),%rax
mov    (%rax),%rdi
lea    0xe63(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11d5 <test+0x95>
mov    0x8(%rsp),%rax
mov    0x8(%rax),%rdi
lea    0xe41(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11d5 <test+0x95>
add    $0x20,%rsp
pop    %rbx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@__const.test.b = [14 x i8] c"hello\0Agoodbye\00"
@.str = [6 x i8] c"hello\00"
@.str.1 = [8 x i8] c"goodbye\00"
define void @test() {
%1 = alloca [14 x i8]
%2 = alloca i32
%3 = alloca i8**
%4 = bitcast [14 x i8]* %1 to i8*
store i32 0, i32* %2
store i8** null, i8*** %3
%5 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 0
%7 = call i32 @strlen(i8* %6)
%8 = call i32 @load_nl_args_buf(i8* %5, i32 %7, i32* %2, i8*** %3)
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 (...) @abort()
unreachable
13: ; preds = %0
%14 = load i8**, i8*** %3
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = call i32 (...) @abort()
unreachable
21: ; preds = %13
%22 = load i8**, i8*** %3
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = call i32 (...) @abort()
unreachable
29: ; preds = %21
ret void
}

LLVM IR (-O2):
@__const.test.b = [14 x i8] c"hello\0Agoodbye\00"
@.str = [6 x i8] c"hello\00"
@.str.1 = [8 x i8] c"goodbye\00"
define void @test() {
%1 = alloca [14 x i8]
%2 = alloca i32
%3 = alloca i8**
%4 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = bitcast i8*** %3 to i8*
store i8** null, i8*** %3
%7 = call i32 @strlen(i8* %4)
%8 = call i32 @load_nl_args_buf(i8* %4, i32 %7, i32* %2, i8*** %3)
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 2
br i1 %10, label %13, label %11
11: ; preds = %0
%12 = call i32 (...) @abort()
unreachable
13: ; preds = %0
%14 = load i8**, i8*** %3
%15 = load i8*, i8** %14
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %13
%19 = call i32 (...) @abort()
unreachable
20: ; preds = %13
%21 = load i8**, i8*** %3
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %20
%27 = call i32 (...) @abort()
unreachable
28: ; preds = %20
ret void
}