#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 dvb_state {
  int dummy;
};

/* Variables and functions */
int dvb_frontend_tune(struct dvb_state *, int, int, int, int, int, int, int,
                      int, int);
int dvb_wait_tune(struct dvb_state *, int);
int dvb_tune(struct dvb_state *h, int frequency, int inversion, int bandwidth,
             int code_rate_high, int code_rate_low, int modulation,
             int transmission, int guard_interval, int hierarchy, int timeout) {
  int rc = 0;
  rc = dvb_frontend_tune(h, frequency, inversion, bandwidth, code_rate_high,
                         code_rate_low, modulation, transmission,
                         guard_interval, hierarchy);
  if (rc != 0)
    return rc;
  rc = dvb_wait_tune(h, timeout);
  if (rc != 0)
    return rc;
  return rc;
}


x86 assembly (clang, -O0):
<dvb_tune>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x48,%rsp
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
mov    %edx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    0x10(%rbp),%ebx
mov    0x18(%rbp),%r11d
mov    0x20(%rbp),%r10d
mov    0x28(%rbp),%eax
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1030 <dvb_frontend_tune@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     11a5 <dvb_tune+0x85>
mov    -0x30(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11cf <dvb_tune+0xaf>
mov    -0x18(%rbp),%rdi
mov    0x30(%rbp),%esi
call   1040 <dvb_wait_tune@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     11c9 <dvb_tune+0xa9>
mov    -0x30(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11cf <dvb_tune+0xaf>
mov    -0x30(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<dvb_tune>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
mov    0x50(%rsp),%r14d
mov    0x30(%rsp),%r10d
mov    0x38(%rsp),%ebp
mov    0x40(%rsp),%ebx
mov    0x48(%rsp),%eax
push   %rax
push   %rbx
push   %rbp
push   %r10
call   1030 <dvb_frontend_tune@plt>
add    $0x20,%rsp
test   %eax,%eax
je     115d <dvb_tune+0x3d>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15,%rdi
mov    %r14d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <dvb_wait_tune@plt>

LLVM IR (-O0):
%struct.dvb_state = type { i32 }
define i32 @dvb_tune(%struct.dvb_state* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10) {
%12 = alloca i32
%13 = alloca %struct.dvb_state*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
store %struct.dvb_state* %0, %struct.dvb_state** %13
store i32 %1, i32* %14
store i32 %2, i32* %15
store i32 %3, i32* %16
store i32 %4, i32* %17
store i32 %5, i32* %18
store i32 %6, i32* %19
store i32 %7, i32* %20
store i32 %8, i32* %21
store i32 %9, i32* %22
store i32 %10, i32* %23
store i32 0, i32* %24
%25 = load %struct.dvb_state*, %struct.dvb_state** %13
%26 = load i32, i32* %14
%27 = load i32, i32* %15
%28 = load i32, i32* %16
%29 = load i32, i32* %17
%30 = load i32, i32* %18
%31 = load i32, i32* %19
%32 = load i32, i32* %20
%33 = load i32, i32* %21
%34 = load i32, i32* %22
%35 = call i32 @dvb_frontend_tune(%struct.dvb_state* %25, i32 %26, i32 %27, i32 %28, i32 %29, i32 %30, i32 %31, i32 %32, i32 %33, i32 %34)
store i32 %35, i32* %24
%36 = load i32, i32* %24
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %11
%39 = load i32, i32* %24
store i32 %39, i32* %12
br label %50
40: ; preds = %11
%41 = load %struct.dvb_state*, %struct.dvb_state** %13
%42 = load i32, i32* %23
%43 = call i32 @dvb_wait_tune(%struct.dvb_state* %41, i32 %42)
store i32 %43, i32* %24
%44 = load i32, i32* %24
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %40
%47 = load i32, i32* %24
store i32 %47, i32* %12
br label %50
48: ; preds = %40
%49 = load i32, i32* %24
store i32 %49, i32* %12
br label %50
50: ; preds = %48, %46, %38
%51 = load i32, i32* %12
ret i32 %51
}

LLVM IR (-O2):
%struct.dvb_state = type { i32 }
define i32 @dvb_tune(%struct.dvb_state* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10) {
%12 = tail call i32 @dvb_frontend_tune(%struct.dvb_state* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @dvb_wait_tune(%struct.dvb_state* %0, i32 %10)
br label %16
16: ; preds = %14, %11
%17 = phi i32 [ %12, %11 ], [ %15, %14 ]
ret i32 %17
}