#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*/ snprintf(char *, size_t, char *, char *);
int latrace_func_to_str_gethostname(void **args, size_t argscnt, char *buf,
                                    size_t blen, void *retval) {
  int *retint;
  char **name;
  if (!retval || (argscnt != 2))
    return -1;
  retint = (int *)retval;
  name = (char **)args[0];
  if (*retint != 0)
    return -1;
  snprintf(buf, blen, "\"%s\"", *name);
  return 0;
}


x86 assembly (clang, -O0):
<latrace_func_to_str_gethostname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1142 <latrace_func_to_str_gethostname+0x32>
cmpq   $0x2,-0x18(%rbp)
je     114e <latrace_func_to_str_gethostname+0x3e>
movl   $0xffffffff,-0x4(%rbp)
jmp    119c <latrace_func_to_str_gethostname+0x8c>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
cmpl   $0x0,(%rax)
je     117a <latrace_func_to_str_gethostname+0x6a>
movl   $0xffffffff,-0x4(%rbp)
jmp    119c <latrace_func_to_str_gethostname+0x8c>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x40(%rbp),%rax
mov    (%rax),%rcx
lea    0xe70(%rip),%rdx
call   1030 <snprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<latrace_func_to_str_gethostname>:
push   %rax
mov    $0xffffffff,%eax
cmp    $0x2,%rsi
jne    1127 <latrace_func_to_str_gethostname+0x17>
test   %r8,%r8
je     1127 <latrace_func_to_str_gethostname+0x17>
cmpl   $0x0,(%r8)
je     1129 <latrace_func_to_str_gethostname+0x19>
pop    %rcx
ret
mov    (%rdi),%rax
mov    (%rax),%rax
lea    0xeca(%rip),%r8
mov    %rdx,%rdi
mov    %rcx,%rsi
mov    %r8,%rdx
mov    %rax,%rcx
call   1030 <snprintf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"\22%s\22\00"
define i32 @latrace_func_to_str_gethostname(i8** nocapture %0, i64 %1, i8* %2, i64 %3, i8* %4) {
%6 = icmp eq i8* %4, null
%7 = icmp ne i64 %1, 2
%8 = or i1 %7, %6
br i1 %8, label %18, label %9
9: ; preds = %5
%10 = bitcast i8* %4 to i32*
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = bitcast i8** %0 to i8***
%15 = load i8**, i8*** %14
%16 = load i8*, i8** %15
%17 = tail call i32 @snprintf(i8* %2, i64 %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %9, %5, %13
%19 = phi i32 [ 0, %13 ], [ -1, %5 ], [ -1, %9 ]
ret i32 %19
}