#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 */
typedef int uint8_t;
typedef int uint64_t;
typedef int uint32_t;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ mkdir(char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, ...);
void prove_path_to(uint64_t keyid, char *what, char *basepath) {
  static char buffer[1024];
  snprintf(buffer, sizeof(buffer), "%s/%s", basepath, what);
  mkdir(buffer, 0777);
  snprintf(buffer, sizeof(buffer), "%s/%s/%02X", basepath, what,
           (uint8_t)((keyid >> 24) & 0xFF));
  mkdir(buffer, 0777);
  snprintf(buffer, sizeof(buffer), "%s/%s/%02X/%02X", basepath, what,
           (uint8_t)((keyid >> 24) & 0xFF), (uint8_t)((keyid >> 16) & 0xFF));
  mkdir(buffer, 0777);
  snprintf(buffer, sizeof(buffer), "%s/%s/%02X/%02X/%08X", basepath, what,
           (uint8_t)((keyid >> 24) & 0xFF), (uint8_t)((keyid >> 16) & 0xFF),
           (uint32_t)(keyid));
  mkdir(buffer, 0777);
}


x86 assembly (clang, -O0):
<prove_path_to>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0x2efe(%rip),%rdi
mov    $0x400,%esi
lea    0xeb2(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    0x2ee4(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x4(%rbp),%r9d
sar    $0x18,%r9d
and    $0xff,%r9d
lea    0x2ebc(%rip),%rdi
mov    $0x400,%esi
lea    0xe76(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    0x2ea2(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x4(%rbp),%r9d
sar    $0x18,%r9d
and    $0xff,%r9d
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
lea    0x2e6f(%rip),%rdi
mov    $0x400,%esi
lea    0xe34(%rip),%rdx
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    0x2e52(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x4(%rbp),%r9d
sar    $0x18,%r9d
and    $0xff,%r9d
mov    -0x4(%rbp),%r10d
sar    $0x10,%r10d
and    $0xff,%r10d
mov    -0x4(%rbp),%eax
lea    0x2e18(%rip),%rdi
mov    $0x400,%esi
lea    0xded(%rip),%rdx
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    0x2df6(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prove_path_to>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %edi,%r14d
lea    0x2f05(%rip),%r15
lea    0xebe(%rip),%rdx
mov    %r15,%rdi
mov    $0x400,%esi
mov    %r12,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %r15,%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
mov    %r14d,%ebp
shr    $0x18,%ebp
lea    0xe95(%rip),%rdx
mov    %r15,%rdi
mov    $0x400,%esi
mov    %r12,%rcx
mov    %rbx,%r8
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %r15,%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
mov    %r14d,%eax
shr    $0x10,%eax
movzbl %al,%r13d
sub    $0x8,%rsp
lea    0xe66(%rip),%rdx
mov    %r15,%rdi
mov    $0x400,%esi
mov    %r12,%rcx
mov    %rbx,%r8
mov    %ebp,%r9d
xor    %eax,%eax
push   %r13
call   1040 <snprintf@plt>
add    $0x10,%rsp
mov    %r15,%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    0xe44(%rip),%rdx
mov    %r15,%rdi
mov    $0x400,%esi
mov    %r12,%rcx
mov    %rbx,%r8
mov    %ebp,%r9d
xor    %eax,%eax
push   %r14
push   %r13
call   1040 <snprintf@plt>
add    $0x10,%rsp
mov    %r15,%rdi
mov    $0x1ff,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <mkdir@plt>

LLVM IR (-O0):
@prove_path_to.buffer = internal global [1024 x i8] zeroinitializer
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [11 x i8] c"%s/%s/%02X\00"
@.str.2 = [16 x i8] c"%s/%s/%02X/%02X\00"
@.str.3 = [21 x i8] c"%s/%s/%02X/%02X/%08X\00"
define void @prove_path_to(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %6
%8 = load i8*, i8** %5
%9 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @prove_path_to.buffer, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %8)
%10 = call i32 @mkdir(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @prove_path_to.buffer, i64 0, i64 0), i32 511)
%11 = load i8*, i8** %6
%12 = load i8*, i8** %5
%13 = load i32, i32* %4
%14 = ashr i32 %13, 24
%15 = and i32 %14, 255
%16 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @prove_path_to.buffer, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %11, i8* %12, i32 %15)
%17 = call i32 @mkdir(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @prove_path_to.buffer, i64 0, i64 0), i32 511)
%18 = load i8*, i8** %6
%19 = load i8*, i8** %5
%20 = load i32, i32* %4
%21 = ashr i32 %20, 24
%22 = and i32 %21, 255
%23 = load i32, i32* %4
%24 = ashr i32 %23, 16
%25 = and i32 %24, 255
%26 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @prove_path_to.buffer, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* %19, i32 %22, i32 %25)
%27 = call i32 @mkdir(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @prove_path_to.buffer, i64 0, i64 0), i32 511)
%28 = load i8*, i8** %6
%29 = load i8*, i8** %5
%30 = load i32, i32* %4
%31 = ashr i32 %30, 24
%32 = and i32 %31, 255
%33 = load i32, i32* %4
%34 = ashr i32 %33, 16
%35 = and i32 %34, 255
%36 = load i32, i32* %4
%37 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @prove_path_to.buffer, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %28, i8* %29, i32 %32, i32 %35, i32 %36)
%38 = call i32 @mkdir(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @prove_path_to.buffer, i64 0, i64 0), i32 511)
ret void
}

LLVM IR (-O2):
@prove_path_to.buffer = internal global [1024 x i8] zeroinitializer
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [11 x i8] c"%s/%s/%02X\00"
@.str.2 = [16 x i8] c"%s/%s/%02X/%02X\00"
@.str.3 = [21 x i8] c"%s/%s/%02X/%02X/%08X\00"
define void @prove_path_to(i32 %0, i8* %1, i8* %2) {
%4 = tail call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @prove_path_to.buffer, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %1)
%5 = tail call i32 @mkdir(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @prove_path_to.buffer, i64 0, i64 0), i32 511)
%6 = lshr i32 %0, 24
%7 = tail call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @prove_path_to.buffer, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %1, i32 %6)
%8 = tail call i32 @mkdir(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @prove_path_to.buffer, i64 0, i64 0), i32 511)
%9 = lshr i32 %0, 16
%10 = and i32 %9, 255
%11 = tail call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @prove_path_to.buffer, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %2, i8* %1, i32 %6, i32 %10)
%12 = tail call i32 @mkdir(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @prove_path_to.buffer, i64 0, i64 0), i32 511)
%13 = tail call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @prove_path_to.buffer, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %2, i8* %1, i32 %6, i32 %10, i32 %0)
%14 = tail call i32 @mkdir(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @prove_path_to.buffer, i64 0, i64 0), i32 511)
ret void
}