#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 errno;
int snprintf(char *, int, char *, char *, char *);
int shmlog_get_master_name(char *prefix, char *path, int path_size) {
  int ret;
  ret = snprintf(path, path_size, "%s-%s", prefix, "master-shm");
  if (ret < 0 || ret >= path_size) {
    do {
      errno = errno < 0 ? errno
                        : (-1 * ((((4) * 10000 + (1522))) * 1000 + (errno)));
    } while (0);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<shmlog_get_master_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rcx
lea    0xecb(%rip),%rdx
lea    0xeca(%rip),%r8
call   1030 <snprintf@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jl     115a <shmlog_get_master_name+0x4a>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     11af <shmlog_get_master_name+0x9f>
jmp    115f <shmlog_get_master_name+0x4f>
mov    0x2e7a(%rip),%rax
cmpl   $0x0,(%rax)
jge    1180 <shmlog_get_master_name+0x70>
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    1197 <shmlog_get_master_name+0x87>
mov    0x2e59(%rip),%rax
mov    (%rax),%eax
add    $0x2799350,%eax
imul   $0xffffffff,%eax,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
mov    0x2e3f(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    11b6 <shmlog_get_master_name+0xa6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shmlog_get_master_name>:
push   %rbx
mov    %edx,%ebx
mov    %rdi,%rcx
lea    0xee3(%rip),%rdx
lea    0xee2(%rip),%r8
mov    %rsi,%rdi
mov    %ebx,%esi
call   1030 <snprintf@plt>
test   %eax,%eax
js     113c <shmlog_get_master_name+0x2c>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ebx,%ecx
jge    113c <shmlog_get_master_name+0x2c>
pop    %rbx
ret
mov    0x2e9d(%rip),%rax
mov    (%rax),%ecx
mov    $0xfd866cb0,%edx
sub    %ecx,%edx
test   %ecx,%ecx
cmovs  %ecx,%edx
mov    %edx,(%rax)
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s-%s\00"
@.str.1 = [11 x i8] c"master-shm\00"
@errno = global i32 0
define i32 @shmlog_get_master_name(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i8*, i8** %6
%10 = load i32, i32* %7
%11 = load i8*, i8** %5
%12 = call i32 @snprintf(i8* %9, i32 %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = icmp slt i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %3
%16 = load i32, i32* %8
%17 = load i32, i32* %7
%18 = icmp sge i32 %16, %17
br i1 %18, label %19, label %32
19: ; preds = %15, %3
br label %20
20: ; preds = %19
%21 = load i32, i32* @errno
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = load i32, i32* @errno
br label %29
25: ; preds = %20
%26 = load i32, i32* @errno
%27 = add nsw i32 41522000, %26
%28 = mul nsw i32 -1, %27
br label %29
29: ; preds = %25, %23
%30 = phi i32 [ %24, %23 ], [ %28, %25 ]
store i32 %30, i32* @errno
br label %31
31: ; preds = %29
store i32 -1, i32* %4
br label %33
32: ; preds = %15
store i32 0, i32* %4
br label %33
33: ; preds = %32, %31
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s-%s\00"
@.str.1 = [11 x i8] c"master-shm\00"
@errno = global i32 0
define i32 @shmlog_get_master_name(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @snprintf(i8* %1, i32 %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp sgt i32 %4, -1
%6 = icmp slt i32 %4, %2
%7 = and i1 %5, %6
br i1 %7, label %13, label %8
8: ; preds = %3
%9 = load i32, i32* @errno
%10 = icmp slt i32 %9, 0
%11 = sub i32 -41522000, %9
%12 = select i1 %10, i32 %9, i32 %11
store i32 %12, i32* @errno
br label %13
13: ; preds = %3, %8
%14 = phi i32 [ -1, %8 ], [ 0, %3 ]
ret i32 %14
}