#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);
void print(char buf[], int x) {
  if (x & 2)
    sprintf(buf, "%d", x);
  else if ((x >>= 2) > 0)
    sprintf(buf, "(Rom+%d)", x);
  else
    sprintf(buf, "(Ram+%d)", -x);
}


x86 assembly (clang, -O0):
<print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1146 <print+0x36>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xec4(%rip),%rsi
call   1030 <sprintf@plt>
jmp    118a <print+0x7a>
mov    -0xc(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jle    1170 <print+0x60>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe9d(%rip),%rsi
call   1030 <sprintf@plt>
jmp    1185 <print+0x75>
mov    -0x8(%rbp),%rdi
xor    %edx,%edx
sub    -0xc(%rbp),%edx
lea    0xe8c(%rip),%rsi
call   1030 <sprintf@plt>
jmp    118a <print+0x7a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print>:
mov    %esi,%eax
test   $0x2,%al
jne    112c <print+0x1c>
mov    %eax,%edx
sar    $0x2,%edx
cmp    $0x4,%eax
jl     113a <print+0x2a>
lea    0xedc(%rip),%rsi
jmp    1030 <sprintf@plt>
lea    0xecd(%rip),%rsi
mov    %eax,%edx
jmp    1030 <sprintf@plt>
neg    %edx
lea    0xec9(%rip),%rsi
jmp    1030 <sprintf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [9 x i8] c"(Rom+%d)\00"
@.str.2 = [9 x i8] c"(Ram+%d)\00"
define void @print(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = and i32 %5, 2
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = load i32, i32* %4
%11 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %26
12: ; preds = %2
%13 = load i32, i32* %4
%14 = ashr i32 %13, 2
store i32 %14, i32* %4
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = load i32, i32* %4
%19 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %25
20: ; preds = %12
%21 = load i8*, i8** %3
%22 = load i32, i32* %4
%23 = sub nsw i32 0, %22
%24 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %20, %16
br label %26
26: ; preds = %25, %8
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [9 x i8] c"(Rom+%d)\00"
@.str.2 = [9 x i8] c"(Ram+%d)\00"
define void @print(i8* nocapture writeonly %0, i32 %1) {
%3 = and i32 %1, 2
%4 = icmp eq i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %15
7: ; preds = %2
%8 = ashr i32 %1, 2
%9 = icmp sgt i32 %1, 3
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %15
12: ; preds = %7
%13 = sub nsw i32 0, %8
%14 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %10, %12, %5
ret void
}