#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 cnv_stat(int val, char *out_val) {
  if (val > 18) {
    int bonus = (val - 18);
    if (bonus >= 100) {
      sprintf(out_val, "18/%03d", bonus);
    } else {
      sprintf(out_val, " 18/%02d", bonus);
    }
  } else {
    sprintf(out_val, "    %2d", val);
  }
}


x86 assembly (clang, -O0):
<cnv_stat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x12,-0x4(%rbp)
jle    116c <cnv_stat+0x5c>
mov    -0x4(%rbp),%eax
sub    $0x12,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jl     1154 <cnv_stat+0x44>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xeb6(%rip),%rsi
call   1030 <sprintf@plt>
jmp    1167 <cnv_stat+0x57>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xea6(%rip),%rsi
call   1030 <sprintf@plt>
jmp    117f <cnv_stat+0x6f>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe97(%rip),%rsi
call   1030 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cnv_stat>:
mov    %rsi,%rcx
mov    %edi,%eax
cmp    $0x13,%edi
jl     1131 <cnv_stat+0x21>
lea    -0x12(%rax),%edx
cmp    $0x76,%eax
jb     1142 <cnv_stat+0x32>
lea    0xed7(%rip),%rsi
mov    %rcx,%rdi
jmp    1030 <sprintf@plt>
lea    0xed9(%rip),%rsi
mov    %rcx,%rdi
mov    %eax,%edx
jmp    1030 <sprintf@plt>
lea    0xebf(%rip),%rsi
mov    %rcx,%rdi
jmp    1030 <sprintf@plt>

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

LLVM IR (-O2):
@.str = [8 x i8] c"18/%03d\00"
@.str.1 = [9 x i8] c" 18/%02d\00"
@.str.2 = [8 x i8] c" %2d\00"
define void @cnv_stat(i32 %0, i8* nocapture writeonly %1) {
%3 = icmp sgt i32 %0, 18
br i1 %3, label %4, label %11
4: ; preds = %2
%5 = add nsw i32 %0, -18
%6 = icmp ugt i32 %0, 117
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %13
9: ; preds = %4
%10 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %5)
br label %13
11: ; preds = %2
%12 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %0)
br label %13
13: ; preds = %7, %9, %11
ret void
}