#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 */
scalar_t__ create_directory(char *, char *);
int snprintf(char *, size_t, char *, char *, char const *);
int store_create(const char *user, size_t size) {
  char store_path[size];
  char resolved[size];
  int ret;
  if (create_directory("/var/lib/sshclip", resolved)) {
    if (user != NULL) {
      ret = snprintf(store_path, size, "%s/%s", resolved, user);
      if (ret && create_directory(store_path, resolved)) {
        return 1;
      }
    } else {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<store_create>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x40(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x30(%rbp)
lea    0xe82(%rip),%rdi
call   1040 <create_directory@plt>
cmp    $0x0,%rax
je     1208 <store_create+0xe8>
cmpq   $0x0,-0x10(%rbp)
je     11f0 <store_create+0xd0>
mov    -0x40(%rbp),%rcx
mov    -0x48(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%r8
lea    0xe62(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     11eb <store_create+0xcb>
mov    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%rdi
call   1040 <create_directory@plt>
cmp    $0x0,%rax
je     11eb <store_create+0xcb>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    1216 <store_create+0xf6>
jmp    1203 <store_create+0xe3>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    1216 <store_create+0xf6>
jmp    1208 <store_create+0xe8>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<store_create>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
mov    %rsp,%r15
lea    0xf(%rsi),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xeab(%rip),%rdi
mov    %rbx,%rsi
call   1040 <create_directory@plt>
test   %rax,%rax
je     1199 <store_create+0x79>
mov    $0x1,%r13d
test   %r14,%r14
je     119c <store_create+0x7c>
lea    0xe9d(%rip),%rdx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rcx
mov    %r14,%r8
call   1030 <snprintf@plt>
test   %eax,%eax
je     1199 <store_create+0x79>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <create_directory@plt>
test   %rax,%rax
jne    119c <store_create+0x7c>
xor    %r13d,%r13d
mov    %r13d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"/var/lib/sshclip\00"
@.str.1 = [6 x i8] c"%s/%s\00"
define i32 @store_create(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i64 %1, i64* %5
%11 = load i64, i64* %5
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %6
%13 = alloca i8, i64 %11
store i64 %11, i64* %7
%14 = load i64, i64* %5
%15 = alloca i8, i64 %14
store i64 %14, i64* %8
%16 = call i64 @create_directory(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %34
18: ; preds = %2
%19 = load i8*, i8** %4
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %32
21: ; preds = %18
%22 = load i64, i64* %5
%23 = load i8*, i8** %4
%24 = call i32 @snprintf(i8* %13, i64 %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %23)
store i32 %24, i32* %9
%25 = load i32, i32* %9
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %21
%28 = call i64 @create_directory(i8* %13, i8* %15)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %27
store i32 1, i32* %3
store i32 1, i32* %10
br label %35
31: ; preds = %27, %21
br label %33
32: ; preds = %18
store i32 1, i32* %3
store i32 1, i32* %10
br label %35
33: ; preds = %31
br label %34
34: ; preds = %33, %2
store i32 0, i32* %3
store i32 1, i32* %10
br label %35
35: ; preds = %34, %32, %30
%36 = load i8*, i8** %6
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [17 x i8] c"/var/lib/sshclip\00"
@.str.1 = [6 x i8] c"%s/%s\00"
define i32 @store_create(i8* %0, i64 %1) {
%3 = alloca i8, i64 %1
%4 = alloca i8, i64 %1
%5 = call i64 @create_directory(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %15, label %7
7: ; preds = %2
%8 = icmp eq i8* %0, null
br i1 %8, label %16, label %9
9: ; preds = %7
%10 = call i32 @snprintf(i8* %3, i64 %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* %0)
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = call i64 @create_directory(i8* %3, i8* %4)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12, %9, %2
br label %16
16: ; preds = %7, %12, %15
%17 = phi i32 [ 0, %15 ], [ 1, %12 ], [ 1, %7 ]
ret i32 %17
}