#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*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ remote_close();
int remote_init();
int /*<<< orphan*/ remote_send(char *);
int /*<<< orphan*/ remote_sig_remote_get_icon(char **);
int /*<<< orphan*/ remote_sig_remote_get_icon_path(char **);
int main(int argc, char *argv[]) {
  char *s;
  if (remote_init() == -1)
    return -1;
  if (argc > 1) {
    remote_send(argv[1]);
    return 0;
  }
  remote_sig_remote_get_icon(&s);
  printf("get_icon -> %s\n", s);
  free(s);
  remote_sig_remote_get_icon_path(&s);
  printf("get_icon_path -> %s\n", s);
  free(s);
  remote_close();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1090 <remote_init@plt>
cmp    $0xffffffff,%eax
jne    11a2 <main+0x32>
movl   $0xffffffff,-0x4(%rbp)
jmp    1217 <main+0xa7>
cmpl   $0x1,-0x8(%rbp)
jle    11c5 <main+0x55>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <remote_send@plt>
movl   $0x0,-0x4(%rbp)
jmp    1217 <main+0xa7>
lea    -0x18(%rbp),%rdi
call   1050 <remote_sig_remote_get_icon@plt>
mov    -0x18(%rbp),%rsi
lea    0xe27(%rip),%rdi
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
lea    -0x18(%rbp),%rdi
call   1080 <remote_sig_remote_get_icon_path@plt>
mov    -0x18(%rbp),%rsi
lea    0xe15(%rip),%rdi
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1060 <remote_close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1090 <remote_init@plt>
cmp    $0xffffffff,%eax
je     1196 <main+0x26>
cmp    $0x2,%ebp
jl     119d <main+0x2d>
mov    0x8(%rbx),%rdi
call   1040 <remote_send@plt>
xor    %ebx,%ebx
jmp    11eb <main+0x7b>
mov    $0xffffffff,%ebx
jmp    11eb <main+0x7b>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <remote_sig_remote_get_icon@plt>
mov    (%rsp),%rsi
lea    0xe4d(%rip),%rdi
call   1070 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1080 <remote_sig_remote_get_icon_path@plt>
mov    (%rsp),%rsi
lea    0xe3c(%rip),%rdi
call   1070 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <remote_close@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"get_icon -> %s\0A\00"
@.str.1 = [21 x i8] c"get_icon_path -> %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (...) @remote_init()
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 -1, i32* %3
br label %30
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @remote_send(i8* %16)
store i32 0, i32* %3
br label %30
18: ; preds = %10
%19 = call i32 @remote_sig_remote_get_icon(i8** %6)
%20 = load i8*, i8** %6
%21 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = load i8*, i8** %6
%23 = call i32 @free(i8* %22)
%24 = call i32 @remote_sig_remote_get_icon_path(i8** %6)
%25 = load i8*, i8** %6
%26 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %6
%28 = call i32 @free(i8* %27)
%29 = call i32 (...) @remote_close()
store i32 0, i32* %3
br label %30
30: ; preds = %18, %13, %9
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [16 x i8] c"get_icon -> %s\0A\00"
@.str.1 = [21 x i8] c"get_icon_path -> %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = tail call i32 (...) @remote_init()
%6 = icmp eq i32 %5, -1
br i1 %6, label %25, label %7
7: ; preds = %2
%8 = icmp sgt i32 %0, 1
br i1 %8, label %9, label %13
9: ; preds = %7
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @remote_send(i8* %11)
br label %25
13: ; preds = %7
%14 = call i32 @remote_sig_remote_get_icon(i8** %3)
%15 = load i8*, i8** %3
%16 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %3
%18 = call i32 @free(i8* %17)
%19 = call i32 @remote_sig_remote_get_icon_path(i8** %3)
%20 = load i8*, i8** %3
%21 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i8*, i8** %3
%23 = call i32 @free(i8* %22)
%24 = call i32 (...) @remote_close()
br label %25
25: ; preds = %2, %13, %9
%26 = phi i32 [ 0, %9 ], [ 0, %13 ], [ -1, %2 ]
ret i32 %26
}