#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 *bucket_path(char *path_last_part, int n_jobs, int job_sn) {
  if (n_jobs <= 4096) {
    sprintf(path_last_part,
            "%d"
            ".bin",
            job_sn);
  } else {
    sprintf(path_last_part,
            "%d/%d"
            ".bin",
            job_sn / 4096, job_sn);
  }
  return path_last_part;
}


x86 assembly (clang, -O0):
<bucket_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x1000,-0xc(%rbp)
jg     1149 <bucket_path+0x39>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xec6(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    116b <bucket_path+0x5b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%eax
mov    $0x1000,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    -0x10(%rbp),%ecx
lea    0xe9c(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bucket_path>:
push   %rbx
mov    %edx,%ecx
mov    %rdi,%rbx
cmp    $0x1000,%esi
jg     1133 <bucket_path+0x23>
lea    0xede(%rip),%rsi
mov    %rbx,%rdi
mov    %ecx,%edx
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    1152 <bucket_path+0x42>
lea    0xfff(%rcx),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
sar    $0xc,%edx
lea    0xeb8(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%d.bin\00"
@.str.1 = [10 x i8] c"%d/%d.bin\00"
define i8* @bucket_path(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
%8 = icmp sle i32 %7, 4096
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = load i32, i32* %6
%12 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %19
13: ; preds = %3
%14 = load i8*, i8** %4
%15 = load i32, i32* %6
%16 = sdiv i32 %15, 4096
%17 = load i32, i32* %6
%18 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %17)
br label %19
19: ; preds = %13, %9
%20 = load i8*, i8** %4
ret i8* %20
}

LLVM IR (-O2):
@.str = [7 x i8] c"%d.bin\00"
@.str.1 = [10 x i8] c"%d/%d.bin\00"
define i8* @bucket_path(i8* returned writeonly %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %1, 4097
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %2)
br label %10
7: ; preds = %3
%8 = sdiv i32 %2, 4096
%9 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %2)
br label %10
10: ; preds = %7, %5
ret i8* %0
}