#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*/ emit(char *, ...);
void ret_timing_checkpoint(int n) {
  if (n) {
    emit("sub edi,%s%d\n", (n < 128) ? "byte " : "", n);
  } else {
    emit("or edi,edi\n");
  }
  emit("jmp exec_checkpoint\n");
}


x86 assembly (clang, -O0):
<ret_timing_checkpoint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1156 <ret_timing_checkpoint+0x46>
mov    -0x4(%rbp),%ecx
lea    0xede(%rip),%rsi
lea    0xed8(%rip),%rax
cmp    $0x80,%ecx
cmovl  %rax,%rsi
mov    -0x4(%rbp),%edx
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <emit@plt>
jmp    1164 <ret_timing_checkpoint+0x54>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <emit@plt>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <emit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ret_timing_checkpoint>:
push   %rax
test   %edi,%edi
je     113f <ret_timing_checkpoint+0x2f>
mov    %edi,%edx
cmp    $0x80,%edi
lea    0xeea(%rip),%rax
lea    0xee2(%rip),%rsi
cmovl  %rax,%rsi
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1030 <emit@plt>
jmp    114d <ret_timing_checkpoint+0x3d>
lea    0xece(%rip),%rdi
xor    %eax,%eax
call   1030 <emit@plt>
lea    0xecc(%rip),%rdi
xor    %eax,%eax
pop    %rcx
jmp    1030 <emit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"sub edi,%s%d\0A\00"
@.str.1 = [6 x i8] c"byte \00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [12 x i8] c"or edi,edi\0A\00"
@.str.4 = [21 x i8] c"jmp exec_checkpoint\0A\00"
define void @ret_timing_checkpoint(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp ne i32 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %1
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 128
%8 = zext i1 %7 to i64
%9 = select i1 %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%10 = load i32, i32* %2
%11 = call i32 (i8*, ...) @emit(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %9, i32 %10)
br label %14
12: ; preds = %1
%13 = call i32 (i8*, ...) @emit(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %14
14: ; preds = %12, %5
%15 = call i32 (i8*, ...) @emit(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"sub edi,%s%d\0A\00"
@.str.1 = [6 x i8] c"byte \00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [12 x i8] c"or edi,edi\0A\00"
@.str.4 = [21 x i8] c"jmp exec_checkpoint\0A\00"
define void @ret_timing_checkpoint(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %7, label %3
3: ; preds = %1
%4 = icmp slt i32 %0, 128
%5 = select i1 %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%6 = tail call i32 (i8*, ...) @emit(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %5, i32 %0)
br label %9
7: ; preds = %1
%8 = tail call i32 (i8*, ...) @emit(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %9
9: ; preds = %7, %3
%10 = tail call i32 (i8*, ...) @emit(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
ret void
}