#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 get_int(char *);
int /*<<< orphan*/ get_str(char *, char *, int);
int /*<<< orphan*/ incr(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ set_str(char *, char *);
void test_redis() {
  int val;
  char buf[100];
  set_str("foo", "100");
  get_str("foo", buf, 100);
  printf("foo: %s\n", buf);
  incr("bar");
  val = get_int("bar");
  printf("bar: %d\n", val);
  get_str("abc", buf, 100);
  printf("abc: %s\n", buf);
  val = get_int("abc");
  printf("abc: %d\n", val);
}


x86 assembly (clang, -O0):
<test_redis>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    0xea1(%rip),%rdi
lea    0xe9e(%rip),%rsi
call   1070 <set_str@plt>
lea    -0x70(%rbp),%rsi
lea    0xe8a(%rip),%rdi
mov    $0x64,%edx
call   1040 <get_str@plt>
lea    -0x70(%rbp),%rsi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe78(%rip),%rdi
call   1050 <incr@plt>
lea    0xe6c(%rip),%rdi
call   1060 <get_int@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe55(%rip),%rdi
mov    $0x64,%edx
call   1040 <get_str@plt>
lea    -0x70(%rbp),%rsi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe32(%rip),%rdi
call   1060 <get_int@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_redis>:
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xea2(%rip),%rbx
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdi
call   1070 <set_str@plt>
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x64,%edx
call   1040 <get_str@plt>
lea    0xe81(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe79(%rip),%rbx
mov    %rbx,%rdi
call   1050 <incr@plt>
mov    %rbx,%rdi
call   1060 <get_int@plt>
lea    0xe66(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe5f(%rip),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x64,%edx
call   1040 <get_str@plt>
lea    0xe4c(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1060 <get_int@plt>
lea    0xe3c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"foo\00"
@.str.1 = [4 x i8] c"100\00"
@.str.2 = [9 x i8] c"foo: %s\0A\00"
@.str.3 = [4 x i8] c"bar\00"
@.str.4 = [9 x i8] c"bar: %d\0A\00"
@.str.5 = [4 x i8] c"abc\00"
@.str.6 = [9 x i8] c"abc: %s\0A\00"
@.str.7 = [9 x i8] c"abc: %d\0A\00"
define void @test_redis() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = call i32 @set_str(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = call i32 @get_str(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4, i32 100)
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%8 = call i32 @incr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @get_int(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i32 %9, i32* %1
%10 = load i32, i32* %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%13 = call i32 @get_str(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %12, i32 100)
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %14)
%16 = call i32 @get_int(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
store i32 %16, i32* %1
%17 = load i32, i32* %1
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 %17)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"foo\00"
@.str.1 = [4 x i8] c"100\00"
@.str.2 = [9 x i8] c"foo: %s\0A\00"
@.str.3 = [4 x i8] c"bar\00"
@.str.4 = [9 x i8] c"bar: %d\0A\00"
@.str.5 = [4 x i8] c"abc\00"
@.str.6 = [9 x i8] c"abc: %s\0A\00"
@.str.7 = [9 x i8] c"abc: %d\0A\00"
define void @test_redis() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @set_str(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @get_str(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2, i32 100)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%6 = call i32 @incr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @get_int(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %7)
%9 = call i32 @get_str(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %2, i32 100)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%11 = call i32 @get_int(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i32 %11)
ret void
}