#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 */
struct test_context {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ get_atts(char const **, char *, char const **,
                            int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ stderr;
void start_test(struct test_context *ctx, const char **atts) {
  const char *name = NULL;
  get_atts(atts, "name", &name, NULL);
  if (!name) {
    fprintf(stderr, "Test with no name\n");
    exit(1);
  }
  printf("%s\n", name);
}


x86 assembly (clang, -O0):
<start_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9d(%rip),%rsi
lea    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <get_atts@plt>
cmpq   $0x0,-0x18(%rbp)
jne    119a <start_test+0x5a>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x18(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_test>:
push   %rax
mov    %rsi,%rdi
movq   $0x0,(%rsp)
lea    0xead(%rip),%rsi
mov    %rsp,%rdx
xor    %ecx,%ecx
call   1040 <get_atts@plt>
mov    (%rsp),%rsi
test   %rsi,%rsi
je     1174 <start_test+0x34>
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
pop    %rax
ret
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.test_context = type { i32 }
@.str = [5 x i8] c"name\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"Test with no name\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @start_test(%struct.test_context* %0, i8** %1) {
%3 = alloca %struct.test_context*
%4 = alloca i8**
%5 = alloca i8*
store %struct.test_context* %0, %struct.test_context** %3
store i8** %1, i8*** %4
store i8* null, i8** %5
%6 = load i8**, i8*** %4
%7 = call i32 @get_atts(i8** %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %5, i32* null)
%8 = load i8*, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i8*, i8** %5
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %15)
ret void
}

LLVM IR (-O2):
%struct.test_context = type { i32 }
@.str = [5 x i8] c"name\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"Test with no name\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @start_test(%struct.test_context* nocapture readnone %0, i8** %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%5 = call i32 @get_atts(i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %3, i32* null)
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %6)
ret void
}