#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ free(char *);
scalar_t__ shittydb_get(char **, char *);
scalar_t__ shittydb_set(char *, char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  char key[] = "test";
  char val[] = "woah i sure hope this works";
  if (shittydb_set(key, val))
    return EXIT_FAILURE;
  char *result = NULL;
  if (shittydb_get(&result, key))
    return EXIT_FAILURE;
  if (strcmp(val, result)) {
    free(result);
    return EXIT_FAILURE;
  }
  free(result);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xea4(%rip),%eax
mov    %eax,-0x15(%rbp)
mov    0xe9f(%rip),%al
mov    %al,-0x11(%rbp)
mov    0xea1(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe9e(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe9b(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe99(%rip),%eax
mov    %eax,-0x28(%rbp)
lea    -0x15(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <shittydb_set@plt>
cmp    $0x0,%rax
je     11ba <main+0x7a>
mov    0x2e30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1230 <main+0xf0>
movq   $0x0,-0x48(%rbp)
lea    -0x15(%rbp),%rsi
lea    -0x48(%rbp),%rdi
call   1060 <shittydb_get@plt>
cmp    $0x0,%rax
je     11ea <main+0xaa>
mov    0x2e00(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1230 <main+0xf0>
lea    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     121b <main+0xdb>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1230 <main+0xf0>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
movb   $0x0,0x4(%rsp)
movl   $0x74736574,(%rsp)
movups 0xec4(%rip),%xmm0
movups %xmm0,0x1c(%rsp)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    %rsp,%rdi
lea    0x10(%rsp),%rsi
call   1050 <shittydb_set@plt>
test   %rax,%rax
jne    11c0 <main+0x80>
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1060 <shittydb_get@plt>
test   %rax,%rax
jne    11c0 <main+0x80>
mov    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcmp@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
test   %rbx,%rbx
jne    11c0 <main+0x80>
mov    0x2e1a(%rip),%rax
jmp    11c7 <main+0x87>
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.key = [5 x i8] c"test\00"
@__const.main.val = [28 x i8] c"woah i sure hope this works\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [5 x i8]
%7 = alloca [28 x i8]
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [5 x i8]* %6 to i8*
%10 = bitcast [28 x i8]* %7 to i8*
%11 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [28 x i8], [28 x i8]* %7, i64 0, i64 0
%13 = call i64 @shittydb_set(i8* %11, i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = load i32, i32* @EXIT_FAILURE
store i32 %16, i32* %3
br label %36
17: ; preds = %2
store i8* null, i8** %8
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%19 = call i64 @shittydb_get(i8** %8, i8* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i32, i32* @EXIT_FAILURE
store i32 %22, i32* %3
br label %36
23: ; preds = %17
%24 = getelementptr inbounds [28 x i8], [28 x i8]* %7, i64 0, i64 0
%25 = load i8*, i8** %8
%26 = call i64 @strcmp(i8* %24, i8* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = load i8*, i8** %8
%30 = call i32 @free(i8* %29)
%31 = load i32, i32* @EXIT_FAILURE
store i32 %31, i32* %3
br label %36
32: ; preds = %23
%33 = load i8*, i8** %8
%34 = call i32 @free(i8* %33)
%35 = load i32, i32* @EXIT_SUCCESS
store i32 %35, i32* %3
br label %36
36: ; preds = %32, %28, %21, %15
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@__const.main.key = [5 x i8] c"test\00"
@__const.main.val = [28 x i8] c"woah i sure hope this works\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [5 x i8]
%4 = alloca [28 x i8]
%5 = alloca i8*
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [28 x i8], [28 x i8]* %4, i64 0, i64 0
%8 = call i64 @shittydb_set(i8* %6, i8* %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = load i32, i32* @EXIT_FAILURE
br label %26
12: ; preds = %2
%13 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%14 = call i64 @shittydb_get(i8** %5, i8* %6)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = load i8*, i8** %5
%18 = call i64 @strcmp(i8* %7, i8* %17)
%19 = icmp eq i64 %18, 0
%20 = load i8*, i8** %5
%21 = call i32 @free(i8* %20)
%22 = select i1 %19, i32* @EXIT_SUCCESS, i32* @EXIT_FAILURE
br label %23
23: ; preds = %16, %12
%24 = phi i32* [ @EXIT_FAILURE, %12 ], [ %22, %16 ]
%25 = load i32, i32* %24
br label %26
26: ; preds = %23, %10
%27 = phi i32 [ %11, %10 ], [ %25, %23 ]
ret i32 %27
}