#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 O_CREAT;
int O_WRONLY;
int /*<<< orphan*/ close(int /*<<< orphan*/);
int /*<<< orphan*/ getuid();
int /*<<< orphan*/ mkdir(char *, int);
int /*<<< orphan*/ open(char *, int, int);
int /*<<< orphan*/ sprintf(char *, char *, int /*<<< orphan*/);
void authOk() {
  mkdir("/run/sudo", 0755);
  mkdir("/run/sudo/auth", 0700);
  char path[256];
  sprintf(path, "/run/sudo/auth/%lu", getuid());
  close(open(path, O_CREAT | O_WRONLY, 0600));
}


x86 assembly (clang, -O0):
<authOk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
lea    0xe9e(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
lea    0xe97(%rip),%rdi
mov    $0x1c0,%esi
call   1030 <mkdir@plt>
lea    -0x100(%rbp),%rax
mov    %rax,-0x108(%rbp)
mov    $0x0,%al
call   1040 <getuid@plt>
mov    -0x108(%rbp),%rdi
mov    %eax,%edx
lea    0xe77(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x100(%rbp),%rdi
mov    0x2e43(%rip),%rax
mov    (%rax),%esi
mov    0x2e12(%rip),%rax
or     (%rax),%esi
mov    $0x180,%edx
call   1060 <open@plt>
mov    %eax,%edi
call   1050 <close@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<authOk>:
push   %rbx
sub    $0x100,%rsp
lea    0xea1(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
lea    0xe9a(%rip),%rdi
mov    $0x1c0,%esi
call   1030 <mkdir@plt>
xor    %eax,%eax
call   1040 <getuid@plt>
lea    0xe91(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%edx
call   1070 <sprintf@plt>
mov    0x2e5c(%rip),%rax
mov    0x2e2d(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %rbx,%rdi
mov    $0x180,%edx
call   1060 <open@plt>
mov    %eax,%edi
add    $0x100,%rsp
pop    %rbx
jmp    1050 <close@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"/run/sudo\00"
@.str.1 = [15 x i8] c"/run/sudo/auth\00"
@.str.2 = [19 x i8] c"/run/sudo/auth/%lu\00"
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
define void @authOk() {
%1 = alloca [256 x i8]
%2 = call i32 @mkdir(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 493)
%3 = call i32 @mkdir(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 448)
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%5 = call i32 (...) @getuid()
%6 = call i32 @sprintf(i8* %4, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%8 = load i32, i32* @O_CREAT
%9 = load i32, i32* @O_WRONLY
%10 = or i32 %8, %9
%11 = call i32 @open(i8* %7, i32 %10, i32 384)
%12 = call i32 @close(i32 %11)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"/run/sudo\00"
@.str.1 = [15 x i8] c"/run/sudo/auth\00"
@.str.2 = [19 x i8] c"/run/sudo/auth/%lu\00"
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
define void @authOk() {
%1 = alloca [256 x i8]
%2 = tail call i32 @mkdir(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 493)
%3 = tail call i32 @mkdir(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 448)
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%5 = tail call i32 (...) @getuid()
%6 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @O_CREAT
%8 = load i32, i32* @O_WRONLY
%9 = or i32 %8, %7
%10 = call i32 @open(i8* %4, i32 %9, i32 384)
%11 = tail call i32 @close(i32 %10)
ret void
}