#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*/ abort();
char *malloc(scalar_t__);
int remote_recv(char *, int);
int remote_send(char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int remote_sig_remote_get_icon_path(char **filepath) {
  char buf[512];
  int i;
  if (remote_send("remote get_icon_path") == -1)
    return -1;
  if ((i = remote_recv((char *)buf, 512)) == -1)
    return -1;
  if (buf[0] != 'o' && buf[1] != 'k' && buf[2] != ' ')
    return -1;
  *filepath = malloc(strlen(buf) - 3);
  if (!*filepath)
    abort();
  strcpy(*filepath, buf + 3);
  return 0;
}


x86 assembly (clang, -O0):
<remote_sig_remote_get_icon_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe8a(%rip),%rdi
call   1050 <remote_send@plt>
cmp    $0xffffffff,%eax
jne    1190 <remote_sig_remote_get_icon_path+0x30>
movl   $0xffffffff,-0x4(%rbp)
jmp    124d <remote_sig_remote_get_icon_path+0xed>
lea    -0x210(%rbp),%rdi
mov    $0x200,%esi
call   1070 <remote_recv@plt>
mov    %eax,-0x214(%rbp)
cmp    $0xffffffff,%eax
jne    11bc <remote_sig_remote_get_icon_path+0x5c>
movl   $0xffffffff,-0x4(%rbp)
jmp    124d <remote_sig_remote_get_icon_path+0xed>
movsbl -0x210(%rbp),%eax
cmp    $0x6f,%eax
je     11f8 <remote_sig_remote_get_icon_path+0x98>
movsbl -0x20f(%rbp),%eax
cmp    $0x6b,%eax
je     11f8 <remote_sig_remote_get_icon_path+0x98>
movsbl -0x20e(%rbp),%eax
cmp    $0x20,%eax
je     11f8 <remote_sig_remote_get_icon_path+0x98>
movl   $0xffffffff,-0x4(%rbp)
jmp    124d <remote_sig_remote_get_icon_path+0xed>
lea    -0x210(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
sub    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    122f <remote_sig_remote_get_icon_path+0xcf>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    -0x210(%rbp),%rsi
add    $0x3,%rsi
call   1040 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remote_sig_remote_get_icon_path>:
push   %rbp
push   %rbx
sub    $0x208,%rsp
mov    %rdi,%rbx
lea    0xe8d(%rip),%rdi
call   1050 <remote_send@plt>
mov    $0xffffffff,%ebp
cmp    $0xffffffff,%eax
je     11d0 <remote_sig_remote_get_icon_path+0x70>
mov    %rsp,%rdi
mov    $0x200,%esi
call   1070 <remote_recv@plt>
cmp    $0xffffffff,%eax
je     11d0 <remote_sig_remote_get_icon_path+0x70>
cmpb   $0x6f,(%rsp)
je     11a8 <remote_sig_remote_get_icon_path+0x48>
cmpb   $0x6b,0x1(%rsp)
je     11a8 <remote_sig_remote_get_icon_path+0x48>
cmpb   $0x20,0x2(%rsp)
jne    11d0 <remote_sig_remote_get_icon_path+0x70>
mov    %rsp,%rdi
call   1060 <strlen@plt>
lea    -0x3(%rax),%rdi
call   1080 <malloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     11dc <remote_sig_remote_get_icon_path+0x7c>
lea    0x3(%rsp),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x208,%rsp
pop    %rbx
pop    %rbp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"remote get_icon_path\00"
define i32 @remote_sig_remote_get_icon_path(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca [512 x i8]
%5 = alloca i32
store i8** %0, i8*** %3
%6 = call i32 @remote_send(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 -1, i32* %2
br label %47
9: ; preds = %1
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%11 = call i32 @remote_recv(i8* %10, i32 512)
store i32 %11, i32* %5
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %14
13: ; preds = %9
store i32 -1, i32* %2
br label %47
14: ; preds = %9
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 111
br i1 %18, label %19, label %30
19: ; preds = %14
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 1
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 107
br i1 %23, label %24, label %30
24: ; preds = %19
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 2
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 32
br i1 %28, label %29, label %30
29: ; preds = %24
store i32 -1, i32* %2
br label %47
30: ; preds = %24, %19, %14
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%32 = call i64 @strlen(i8* %31)
%33 = sub nsw i64 %32, 3
%34 = call i8* @malloc(i64 %33)
%35 = load i8**, i8*** %3
store i8* %34, i8** %35
%36 = load i8**, i8*** %3
%37 = load i8*, i8** %36
%38 = icmp ne i8* %37, null
br i1 %38, label %41, label %39
39: ; preds = %30
%40 = call i32 (...) @abort()
unreachable
41: ; preds = %30
%42 = load i8**, i8*** %3
%43 = load i8*, i8** %42
%44 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%45 = getelementptr inbounds i8, i8* %44, i64 3
%46 = call i32 @strcpy(i8* %43, i8* %45)
store i32 0, i32* %2
br label %47
47: ; preds = %41, %29, %13, %8
%48 = load i32, i32* %2
ret i32 %48
}

LLVM IR (-O2):
@.str = [21 x i8] c"remote get_icon_path\00"
define i32 @remote_sig_remote_get_icon_path(i8** nocapture writeonly %0) {
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @remote_send(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, -1
br i1 %5, label %30, label %6
6: ; preds = %1
%7 = call i32 @remote_recv(i8* %3, i32 512)
%8 = icmp eq i32 %7, -1
br i1 %8, label %30, label %9
9: ; preds = %6
%10 = load i8, i8* %3
%11 = icmp ne i8 %10, 111
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 1
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 107
%15 = select i1 %11, i1 %14, i1 false
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 2
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 32
%19 = select i1 %15, i1 %18, i1 false
br i1 %19, label %30, label %20
20: ; preds = %9
%21 = call i64 @strlen(i8* %3)
%22 = add nsw i64 %21, -3
%23 = call i8* @malloc(i64 %22)
store i8* %23, i8** %0
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = call i32 (...) @abort()
unreachable
27: ; preds = %20
%28 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 3
%29 = call i32 @strcpy(i8* %23, i8* %28)
br label %30
30: ; preds = %9, %6, %1, %27
%31 = phi i32 [ 0, %27 ], [ -1, %1 ], [ -1, %6 ], [ -1, %9 ]
ret i32 %31
}