#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int fflush(int /*<<< orphan*/ *);
int fprintf(int /*<<< orphan*/ *, char *);
void gpio_write(FILE *f, int fl) {
  if (f) {
    int res = fprintf(f, fl ? "1\n" : "0\n");
    assert(res == 2);
    res = fflush(f);
    assert(res == 0);
  }
}


x86 assembly (clang, -O0):
<gpio_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     119c <gpio_write+0x6c>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%ecx
lea    0xeab(%rip),%rsi
lea    0xea1(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
call   1040 <fprintf@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x2,-0x10(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1050 <fflush@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gpio_write>:
test   %rdi,%rdi
je     1176 <gpio_write+0x46>
push   %rbx
mov    %rdi,%rbx
test   %esi,%esi
lea    0xec1(%rip),%rax
lea    0xeb7(%rip),%rsi
cmove  %rax,%rsi
call   1040 <fprintf@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1030 <assert@plt>
mov    %rbx,%rdi
call   1050 <fflush@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
pop    %rbx
jmp    1030 <assert@plt>
ret

LLVM IR (-O0):
@.str = [3 x i8] c"1\0A\00"
@.str.1 = [3 x i8] c"0\0A\00"
define void @gpio_write(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32*, i32** %3
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %25
8: ; preds = %2
%9 = load i32*, i32** %3
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
%12 = zext i1 %11 to i64
%13 = select i1 %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%14 = call i32 @fprintf(i32* %9, i8* %13)
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 2
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32*, i32** %3
%20 = call i32 @fflush(i32* %19)
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = icmp eq i32 %21, 0
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
br label %25
25: ; preds = %8, %2
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"1\0A\00"
@.str.1 = [3 x i8] c"0\0A\00"
define void @gpio_write(i32* %0, i32 %1) {
%3 = icmp eq i32* %0, null
br i1 %3, label %15, label %4
4: ; preds = %2
%5 = icmp eq i32 %1, 0
%6 = select i1 %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0)
%7 = tail call i32 @fprintf(i32* %0, i8* %6)
%8 = icmp eq i32 %7, 2
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call i32 @fflush(i32* %0)
%12 = icmp eq i32 %11, 0
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
br label %15
15: ; preds = %4, %2
ret void
}