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

/* Variables and functions */
int O_RDONLY;
int O_SYNC;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int open(char *, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ write(int, char *, int);
int main() {
  int muons = open("/dev/muon_timer", O_RDONLY);
  int pulse = open("/sys/class/muon_timer/muon_timer/pulse", O_WRONLY | O_SYNC);
  sleep(1);
  char one = '1';
  write(pulse, &one, sizeof(one));
  close(pulse);
  close(muons);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%esi
lea    0xea1(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
mov    0x2e71(%rip),%rax
or     (%rax),%esi
lea    0xe90(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0xc(%rbp)
mov    $0x1,%edi
call   1060 <sleep@plt>
movb   $0x31,-0xd(%rbp)
mov    -0xc(%rbp),%edi
lea    -0xd(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0xc(%rbp),%edi
call   1040 <close@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    0x2e96(%rip),%rax
mov    (%rax),%esi
lea    0xead(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebx
mov    0x2e67(%rip),%rax
mov    0x2e80(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe9d(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebp
mov    $0x1,%edi
call   1060 <sleep@plt>
movb   $0x31,0x7(%rsp)
lea    0x7(%rsp),%rsi
mov    %ebp,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %ebp,%edi
call   1040 <close@plt>
mov    %ebx,%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"/dev/muon_timer\00"
@O_RDONLY = global i32 0
@.str.1 = [39 x i8] c"/sys/class/muon_timer/muon_timer/pulse\00"
@O_WRONLY = global i32 0
@O_SYNC = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 0, i32* %1
%5 = load i32, i32* @O_RDONLY
%6 = call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %5)
store i32 %6, i32* %2
%7 = load i32, i32* @O_WRONLY
%8 = load i32, i32* @O_SYNC
%9 = or i32 %7, %8
%10 = call i32 @open(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %9)
store i32 %10, i32* %3
%11 = call i32 @sleep(i32 1)
store i8 49, i8* %4
%12 = load i32, i32* %3
%13 = call i32 @write(i32 %12, i8* %4, i32 1)
%14 = load i32, i32* %3
%15 = call i32 @close(i32 %14)
%16 = load i32, i32* %2
%17 = call i32 @close(i32 %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"/dev/muon_timer\00"
@O_RDONLY = global i32 0
@.str.1 = [39 x i8] c"/sys/class/muon_timer/muon_timer/pulse\00"
@O_WRONLY = global i32 0
@O_SYNC = global i32 0
define i32 @main() {
%1 = alloca i8
%2 = load i32, i32* @O_RDONLY
%3 = tail call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = load i32, i32* @O_WRONLY
%5 = load i32, i32* @O_SYNC
%6 = or i32 %5, %4
%7 = tail call i32 @open(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = tail call i32 @sleep(i32 1)
store i8 49, i8* %1
%9 = call i32 @write(i32 %7, i8* %1, i32 1)
%10 = tail call i32 @close(i32 %7)
%11 = tail call i32 @close(i32 %3)
ret i32 0
}