#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*/ sprintf(char *, char *, int);
char *oft(int i) {
  static char buf[32];
  if (i < 0)
    sprintf(buf, "%d", i);
  else if (i == 0)
    *buf = 0;
  else
    sprintf(buf, "+%d", i);
  return buf;
}


x86 assembly (clang, -O0):
<oft>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1140 <oft+0x30>
mov    -0x4(%rbp),%edx
lea    0x2f11(%rip),%rdi
lea    0xecb(%rip),%rsi
call   1030 <sprintf@plt>
jmp    1171 <oft+0x61>
cmpl   $0x0,-0x4(%rbp)
jne    1156 <oft+0x46>
movb   $0x0,0x2eef(%rip)
jmp    116c <oft+0x5c>
mov    -0x4(%rbp),%edx
lea    0x2ee0(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1030 <sprintf@plt>
jmp    1171 <oft+0x61>
lea    0x2ec8(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oft>:
push   %rax
mov    %edi,%edx
test   %edi,%edi
js     1129 <oft+0x19>
je     113e <oft+0x2e>
lea    0x2f20(%rip),%rdi
lea    0xed9(%rip),%rsi
jmp    1137 <oft+0x27>
lea    0x2f10(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1030 <sprintf@plt>
jmp    1145 <oft+0x35>
movb   $0x0,0x2efb(%rip)
lea    0x2ef4(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@oft.buf = internal global [32 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"+%d\00"
define i8* @oft(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* %2
%7 = call i32 @sprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @oft.buf, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %16
8: ; preds = %1
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %8
store i8 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @oft.buf, i64 0, i64 0)
br label %15
12: ; preds = %8
%13 = load i32, i32* %2
%14 = call i32 @sprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @oft.buf, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %12, %11
br label %16
16: ; preds = %15, %5
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @oft.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@oft.buf = internal global [32 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"+%d\00"
define i8* @oft(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @oft.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %10
5: ; preds = %1
%6 = icmp eq i32 %0, 0
br i1 %6, label %7, label %8
7: ; preds = %5
store i8 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @oft.buf, i64 0, i64 0)
br label %10
8: ; preds = %5
%9 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @oft.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %10
10: ; preds = %7, %8, %3
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @oft.buf, i64 0, i64 0)
}