#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 sparse_dict {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sparse_dict_free(struct sparse_dict *);
char *sparse_dict_get(struct sparse_dict *, char *, size_t, size_t *);
struct sparse_dict *sparse_dict_init();
int /*<<< orphan*/ sparse_dict_set(struct sparse_dict *, char *, size_t, char *,
                                   size_t);
size_t strlen(char *);
scalar_t__ strncmp(char const *, char *, size_t);
int test_dict_get() {
  struct sparse_dict *dict = NULL;
  size_t outsize = 0;
  const char *value = NULL;
  dict = sparse_dict_init();
  if (!(dict)) {
    printf("%i: ", 199);
    return 0;
  };
  if (!(sparse_dict_set(dict, "key", strlen("key"), "value",
                        strlen("value")))) {
    printf("%i: ", 201);
    return 0;
  };
  value = sparse_dict_get(dict, "key", strlen("key"), &outsize);
  if (!(value)) {
    printf("%i: ", 205);
    return 0;
  };
  if (!(outsize == strlen("value"))) {
    printf("%i: ", 206);
    return 0;
  };
  if (!(strncmp(value, "value", outsize) == 0)) {
    printf("%i: ", 207);
    return 0;
  };
  if (!(sparse_dict_free(dict))) {
    printf("%i: ", 209);
    return 0;
  };
  return 1;
}


x86 assembly (clang, -O0):
<test_dict_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1070 <sparse_dict_init@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11c3 <test_dict_get+0x53>
lea    0xe53(%rip),%rdi
mov    $0xc7,%esi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1334 <test_dict_get+0x1c4>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    0xe33(%rip),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
lea    0xe27(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    %rax,%r8
lea    0xe0c(%rip),%rsi
lea    0xe09(%rip),%rcx
call   1080 <sparse_dict_set@plt>
cmp    $0x0,%eax
jne    122b <test_dict_get+0xbb>
lea    0xdeb(%rip),%rdi
mov    $0xc9,%esi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1334 <test_dict_get+0x1c4>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xdcb(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rdx
lea    0xdb8(%rip),%rsi
lea    -0x18(%rbp),%rcx
call   1050 <sparse_dict_get@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1282 <test_dict_get+0x112>
lea    0xd94(%rip),%rdi
mov    $0xcd,%esi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1334 <test_dict_get+0x1c4>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    0xd78(%rip),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
je     12c3 <test_dict_get+0x153>
lea    0xd53(%rip),%rdi
mov    $0xce,%esi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1334 <test_dict_get+0x1c4>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xd37(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     12fe <test_dict_get+0x18e>
lea    0xd18(%rip),%rdi
mov    $0xcf,%esi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1334 <test_dict_get+0x1c4>
mov    -0x10(%rbp),%rdi
call   1090 <sparse_dict_free@plt>
cmp    $0x0,%eax
jne    132d <test_dict_get+0x1bd>
lea    0xce9(%rip),%rdi
mov    $0xd1,%esi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1334 <test_dict_get+0x1c4>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_dict_get>:
push   %rbp
push   %rbx
push   %rax
movq   $0x0,(%rsp)
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <sparse_dict_init@plt>
test   %rax,%rax
je     11eb <test_dict_get+0x8b>
mov    %rax,%rbx
lea    0xe82(%rip),%rsi
lea    0xe7f(%rip),%rcx
mov    $0x3,%edx
mov    $0x5,%r8d
mov    %rax,%rdi
call   1070 <sparse_dict_set@plt>
test   %eax,%eax
je     11fe <test_dict_get+0x9e>
lea    0xe5d(%rip),%rsi
mov    %rsp,%rcx
mov    $0x3,%edx
mov    %rbx,%rdi
call   1040 <sparse_dict_get@plt>
test   %rax,%rax
je     120c <test_dict_get+0xac>
cmpq   $0x5,(%rsp)
jne    121a <test_dict_get+0xba>
lea    0xe3e(%rip),%rsi
mov    $0x5,%edx
mov    %rax,%rdi
call   1030 <strncmp@plt>
test   %rax,%rax
je     1236 <test_dict_get+0xd6>
lea    0xe1c(%rip),%rdi
mov    $0xcf,%esi
jmp    1226 <test_dict_get+0xc6>
lea    0xe0e(%rip),%rdi
mov    $0xc7,%esi
call   1050 <printf@plt>
jmp    122d <test_dict_get+0xcd>
lea    0xdfb(%rip),%rdi
mov    $0xc9,%esi
jmp    1226 <test_dict_get+0xc6>
lea    0xded(%rip),%rdi
mov    $0xcd,%esi
jmp    1226 <test_dict_get+0xc6>
lea    0xddf(%rip),%rdi
mov    $0xce,%esi
call   1050 <printf@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %rbx,%rdi
call   1080 <sparse_dict_free@plt>
mov    $0x1,%ebp
test   %eax,%eax
jne    122d <test_dict_get+0xcd>
lea    0xdb2(%rip),%rdi
mov    $0xd1,%esi
jmp    1226 <test_dict_get+0xc6>

LLVM IR (-O0):
%struct.sparse_dict = type { i32 }
@.str = [5 x i8] c"%i: \00"
@.str.1 = [4 x i8] c"key\00"
@.str.2 = [6 x i8] c"value\00"
define i32 @test_dict_get() {
%1 = alloca i32
%2 = alloca %struct.sparse_dict*
%3 = alloca i64
%4 = alloca i8*
store %struct.sparse_dict* null, %struct.sparse_dict** %2
store i64 0, i64* %3
store i8* null, i8** %4
%5 = call %struct.sparse_dict* (...) @sparse_dict_init()
store %struct.sparse_dict* %5, %struct.sparse_dict** %2
%6 = load %struct.sparse_dict*, %struct.sparse_dict** %2
%7 = icmp ne %struct.sparse_dict* %6, null
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 199)
store i32 0, i32* %1
br label %46
10: ; preds = %0
%11 = load %struct.sparse_dict*, %struct.sparse_dict** %2
%12 = call i64 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = call i64 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @sparse_dict_set(%struct.sparse_dict* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %10
%17 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 201)
store i32 0, i32* %1
br label %46
18: ; preds = %10
%19 = load %struct.sparse_dict*, %struct.sparse_dict** %2
%20 = call i64 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%21 = call i8* @sparse_dict_get(%struct.sparse_dict* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %20, i64* %3)
store i8* %21, i8** %4
%22 = load i8*, i8** %4
%23 = icmp ne i8* %22, null
br i1 %23, label %26, label %24
24: ; preds = %18
%25 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 205)
store i32 0, i32* %1
br label %46
26: ; preds = %18
%27 = load i64, i64* %3
%28 = call i64 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i64 %27, %28
br i1 %29, label %32, label %30
30: ; preds = %26
%31 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 206)
store i32 0, i32* %1
br label %46
32: ; preds = %26
%33 = load i8*, i8** %4
%34 = load i64, i64* %3
%35 = call i64 @strncmp(i8* %33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %32
%38 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 207)
store i32 0, i32* %1
br label %46
39: ; preds = %32
%40 = load %struct.sparse_dict*, %struct.sparse_dict** %2
%41 = call i32 @sparse_dict_free(%struct.sparse_dict* %40)
%42 = icmp ne i32 %41, 0
br i1 %42, label %45, label %43
43: ; preds = %39
%44 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 209)
store i32 0, i32* %1
br label %46
45: ; preds = %39
store i32 1, i32* %1
br label %46
46: ; preds = %45, %43, %37, %30, %24, %16, %8
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
%struct.sparse_dict = type { i32 }
@.str = [5 x i8] c"%i: \00"
@.str.1 = [4 x i8] c"key\00"
@.str.2 = [6 x i8] c"value\00"
define i32 @test_dict_get() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%3 = tail call %struct.sparse_dict* (...) @sparse_dict_init()
%4 = icmp eq %struct.sparse_dict* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 199)
br label %32
7: ; preds = %0
%8 = tail call i32 @sparse_dict_set(%struct.sparse_dict* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 201)
br label %32
12: ; preds = %7
%13 = call i8* @sparse_dict_get(%struct.sparse_dict* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 3, i64* %1)
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 205)
br label %32
17: ; preds = %12
%18 = load i64, i64* %1
%19 = icmp eq i64 %18, 5
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 206)
br label %32
22: ; preds = %17
%23 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 5)
%24 = icmp eq i64 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 207)
br label %32
27: ; preds = %22
%28 = call i32 @sparse_dict_free(%struct.sparse_dict* %3)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 209)
br label %32
32: ; preds = %27, %30, %25, %20, %15, %10, %5
%33 = phi i32 [ 0, %30 ], [ 0, %25 ], [ 0, %20 ], [ 0, %15 ], [ 0, %10 ], [ 0, %5 ], [ 1, %27 ]
ret i32 %33
}