#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 */
struct ir_remote {
  int dummy;
};
struct ir_ncode {
  int dummy;
};

/* Variables and functions */
scalar_t__ parse_rc(int, char *, char *, struct ir_remote **,
                    struct ir_ncode **, int /*<<< orphan*/ *,
                    int /*<<< orphan*/, int *);
int send_name(int, char *, struct ir_ncode *);
int send_remote(int, char *, struct ir_remote *);
int send_remote_list(int, char *);
int list(int fd, char *message, char *arguments) {
  struct ir_remote *remote;
  struct ir_ncode *code;
  int err;
  if (parse_rc(fd, message, arguments, &remote, &code, NULL, 0, &err) == 0)
    return 0;
  if (err)
    return 1;
  if (remote == NULL) {
    return (send_remote_list(fd, message));
  }
  if (code == NULL) {
    return (send_remote(fd, message, remote));
  }
  return (send_name(fd, message, code));
}


x86 assembly (clang, -O0):
<list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%r8
xor    %eax,%eax
mov    %eax,%r9d
xor    %eax,%eax
lea    -0x2c(%rbp),%rax
movl   $0x0,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <parse_rc@plt>
cmp    $0x0,%rax
jne    1198 <list+0x58>
movl   $0x0,-0x4(%rbp)
jmp    1203 <list+0xc3>
cmpl   $0x0,-0x2c(%rbp)
je     11ae <list+0x6e>
movl   $0x1,-0x4(%rbp)
jmp    1203 <list+0xc3>
cmpq   $0x0,-0x20(%rbp)
jne    11cd <list+0x8d>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <send_remote_list@plt>
mov    %eax,-0x4(%rbp)
jmp    1203 <list+0xc3>
cmpq   $0x0,-0x28(%rbp)
jne    11f0 <list+0xb0>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <send_remote@plt>
mov    %eax,-0x4(%rbp)
jmp    1203 <list+0xc3>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1050 <send_name@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xc(%rsp),%rax
xor    %ebx,%ebx
lea    0x18(%rsp),%rcx
lea    0x10(%rsp),%r8
xor    %r9d,%r9d
push   %rax
push   $0x0
call   1040 <parse_rc@plt>
add    $0x10,%rsp
test   %rax,%rax
je     11b4 <list+0x74>
mov    $0x1,%ebx
cmpl   $0x0,0xc(%rsp)
jne    11b4 <list+0x74>
mov    0x18(%rsp),%rdx
test   %rdx,%rdx
je     11a1 <list+0x61>
mov    0x10(%rsp),%rax
mov    %ebp,%edi
mov    %r14,%rsi
test   %rax,%rax
je     11ad <list+0x6d>
mov    %rax,%rdx
call   1050 <send_name@plt>
jmp    11b2 <list+0x72>
mov    %ebp,%edi
mov    %r14,%rsi
call   1060 <send_remote_list@plt>
jmp    11b2 <list+0x72>
call   1030 <send_remote@plt>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.ir_remote = type { i32 }
%struct.ir_ncode = type { i32 }
define i32 @list(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.ir_remote*
%9 = alloca %struct.ir_ncode*
%10 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%11 = load i32, i32* %5
%12 = load i8*, i8** %6
%13 = load i8*, i8** %7
%14 = call i64 @parse_rc(i32 %11, i8* %12, i8* %13, %struct.ir_remote** %8, %struct.ir_ncode** %9, i32* null, i32 0, i32* %10)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %3
store i32 0, i32* %4
br label %41
17: ; preds = %3
%18 = load i32, i32* %10
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %17
store i32 1, i32* %4
br label %41
21: ; preds = %17
%22 = load %struct.ir_remote*, %struct.ir_remote** %8
%23 = icmp eq %struct.ir_remote* %22, null
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load i32, i32* %5
%26 = load i8*, i8** %6
%27 = call i32 @send_remote_list(i32 %25, i8* %26)
store i32 %27, i32* %4
br label %41
28: ; preds = %21
%29 = load %struct.ir_ncode*, %struct.ir_ncode** %9
%30 = icmp eq %struct.ir_ncode* %29, null
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = load i32, i32* %5
%33 = load i8*, i8** %6
%34 = load %struct.ir_remote*, %struct.ir_remote** %8
%35 = call i32 @send_remote(i32 %32, i8* %33, %struct.ir_remote* %34)
store i32 %35, i32* %4
br label %41
36: ; preds = %28
%37 = load i32, i32* %5
%38 = load i8*, i8** %6
%39 = load %struct.ir_ncode*, %struct.ir_ncode** %9
%40 = call i32 @send_name(i32 %37, i8* %38, %struct.ir_ncode* %39)
store i32 %40, i32* %4
br label %41
41: ; preds = %36, %31, %24, %20, %16
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
%struct.ir_remote = type { i32 }
%struct.ir_ncode = type { i32 }
define i32 @list(i32 %0, i8* %1, i8* %2) {
%4 = alloca %struct.ir_remote*
%5 = alloca %struct.ir_ncode*
%6 = alloca i32
%7 = bitcast %struct.ir_remote** %4 to i8*
%8 = bitcast %struct.ir_ncode** %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = call i64 @parse_rc(i32 %0, i8* %1, i8* %2, %struct.ir_remote** %4, %struct.ir_ncode** %5, i32* null, i32 0, i32* %6)
%11 = icmp eq i64 %10, 0
br i1 %11, label %27, label %12
12: ; preds = %3
%13 = load i32, i32* %6
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %27
15: ; preds = %12
%16 = load %struct.ir_remote*, %struct.ir_remote** %4
%17 = icmp eq %struct.ir_remote* %16, null
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @send_remote_list(i32 %0, i8* %1)
br label %27
20: ; preds = %15
%21 = load %struct.ir_ncode*, %struct.ir_ncode** %5
%22 = icmp eq %struct.ir_ncode* %21, null
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @send_remote(i32 %0, i8* %1, %struct.ir_remote* %16)
br label %27
25: ; preds = %20
%26 = call i32 @send_name(i32 %0, i8* %1, %struct.ir_ncode* %21)
br label %27
27: ; preds = %12, %3, %25, %23, %18
%28 = phi i32 [ %19, %18 ], [ %24, %23 ], [ %26, %25 ], [ 0, %3 ], [ 1, %12 ]
ret i32 %28
}