#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_client {
  int dummy;
};
typedef scalar_t__ int64_t;

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


x86 assembly (clang, -O0):
<chirp_client_fsync>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <chirp_client_fsync_begin@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jl     1167 <chirp_client_fsync+0x47>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <get_result@plt>
mov    %rax,-0x8(%rbp)
jmp    116f <chirp_client_fsync+0x4f>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chirp_client_fsync>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rdi,%rbx
call   1040 <chirp_client_fsync_begin@plt>
test   %rax,%rax
js     1142 <chirp_client_fsync+0x22>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <get_result@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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