#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*/ printf(char *, int, ...);
int function(int i, char *s) {
  int ret;
  char *m = s;
  if (!s)
    m = "(null)";
  printf(" CALLED: function(%d, %s).\n", i, m);
  ret = i + 1;
  printf(" RETURN: %d = function(%d, %s).\n", ret, i, m);
  return ret;
}


x86 assembly (clang, -O0):
<function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113d <function+0x2d>
lea    0xec7(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x20(%rbp),%rdx
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x20(%rbp),%rcx
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<function>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
test   %rsi,%rsi
lea    0xedf(%rip),%rbx
cmovne %rsi,%rbx
lea    0xedb(%rip),%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x1(%r14),%ebp
lea    0xedf(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"(null)\00"
@.str.1 = [28 x i8] c" CALLED: function(%d, %s).\0A\00"
@.str.2 = [33 x i8] c" RETURN: %d = function(%d, %s).\0A\00"
define i32 @function(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
store i8* %7, i8** %6
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %6
br label %11
11: ; preds = %10, %2
%12 = load i32, i32* %3
%13 = load i8*, i8** %6
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %12, i8* %13)
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = load i32, i32* %3
%19 = load i8*, i8** %6
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %18, i8* %19)
%21 = load i32, i32* %5
ret i32 %21
}

LLVM IR (-O2):
@.str = [7 x i8] c"(null)\00"
@.str.1 = [28 x i8] c" CALLED: function(%d, %s).\0A\00"
@.str.2 = [33 x i8] c" RETURN: %d = function(%d, %s).\0A\00"
define i32 @function(i32 %0, i8* %1) {
%3 = icmp eq i8* %1, null
%4 = select i1 %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %1
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %0, i8* %4)
%6 = add nsw i32 %0, 1
%7 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %6, i32 %0, i8* %4)
ret i32 %6
}