#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 */
typedef int /*<<< orphan*/ time_t;
struct chirp_stat {
  int dummy;
};
struct chirp_client {
  int dummy;
};
typedef scalar_t__ int64_t;

/* Variables and functions */
scalar_t__ get_result(struct chirp_client *, int /*<<< orphan*/);
scalar_t__ get_stat_result(struct chirp_client *, int /*<<< orphan*/ *,
                           struct chirp_stat *, int /*<<< orphan*/);
int64_t chirp_client_fstat_finish(struct chirp_client *c, int64_t fd,
                                  struct chirp_stat *info, time_t stoptime) {
  int64_t result = get_result(c, stoptime);
  if (result >= 0)
    return get_stat_result(c, NULL, info, stoptime);
  return result;
}


x86 assembly (clang, -O0):
<chirp_client_fstat_finish>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1030 <get_result@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jl     116f <chirp_client_fstat_finish+0x4f>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
xor    %eax,%eax
mov    %eax,%esi
call   1040 <get_stat_result@plt>
mov    %rax,-0x8(%rbp)
jmp    1177 <chirp_client_fstat_finish+0x57>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chirp_client_fstat_finish>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rdi,%rbx
mov    %ecx,%esi
call   1030 <get_result@plt>
test   %rax,%rax
js     114b <chirp_client_fstat_finish+0x2b>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r14,%rdx
mov    %ebp,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <get_stat_result@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.chirp_client = type { i32 }
%struct.chirp_stat = type { i32 }
define i64 @chirp_client_fstat_finish(%struct.chirp_client* %0, i64 %1, %struct.chirp_stat* %2, i32 %3) {
%5 = alloca i64
%6 = alloca %struct.chirp_client*
%7 = alloca i64
%8 = alloca %struct.chirp_stat*
%9 = alloca i32
%10 = alloca i64
store %struct.chirp_client* %0, %struct.chirp_client** %6
store i64 %1, i64* %7
store %struct.chirp_stat* %2, %struct.chirp_stat** %8
store i32 %3, i32* %9
%11 = load %struct.chirp_client*, %struct.chirp_client** %6
%12 = load i32, i32* %9
%13 = call i64 @get_result(%struct.chirp_client* %11, i32 %12)
store i64 %13, i64* %10
%14 = load i64, i64* %10
%15 = icmp sge i64 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %4
%17 = load %struct.chirp_client*, %struct.chirp_client** %6
%18 = load %struct.chirp_stat*, %struct.chirp_stat** %8
%19 = load i32, i32* %9
%20 = call i64 @get_stat_result(%struct.chirp_client* %17, i32* null, %struct.chirp_stat* %18, i32 %19)
store i64 %20, i64* %5
br label %23
21: ; preds = %4
%22 = load i64, i64* %10
store i64 %22, i64* %5
br label %23
23: ; preds = %21, %16
%24 = load i64, i64* %5
ret i64 %24
}

LLVM IR (-O2):
%struct.chirp_client = type { i32 }
%struct.chirp_stat = type { i32 }
define i64 @chirp_client_fstat_finish(%struct.chirp_client* %0, i64 %1, %struct.chirp_stat* %2, i32 %3) {
%5 = tail call i64 @get_result(%struct.chirp_client* %0, i32 %3)
%6 = icmp sgt i64 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i64 @get_stat_result(%struct.chirp_client* %0, i32* null, %struct.chirp_stat* %2, i32 %3)
br label %9
9: ; preds = %4, %7
%10 = phi i64 [ %8, %7 ], [ %5, %4 ]
ret i64 %10
}