#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ usleep(int);
int main(void) {
  int buff_size = 256;
  FILE *fp;
  char buff[buff_size];
  while (1) {
    if ((fp = fopen("/dev/rtlightsensor0", "r")) != NULL) {
      while (fgets(buff, buff_size, fp) != NULL) {
        printf("%s", buff);
      }
    }
    fclose(fp);
    usleep(500 * 1000);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x100,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
jmp    1191 <main+0x41>
lea    0xe68(%rip),%rdi
lea    0xe75(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11eb <main+0x9b>
jmp    11b7 <main+0x67>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11e6 <main+0x96>
mov    -0x28(%rbp),%rsi
lea    0xe3a(%rip),%rdi
call   1040 <printf@plt>
jmp    11b7 <main+0x67>
jmp    11eb <main+0x9b>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
jmp    118c <main+0x3c>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100,%rsp
lea    0xe99(%rip),%r14
lea    0xea6(%rip),%r15
mov    %rsp,%r13
lea    0xe9e(%rip),%r12
jmp    1192 <main+0x42>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    $0x7a120,%edi
call   1070 <usleep@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1180 <main+0x30>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1180 <main+0x30>
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <printf@plt>
jmp    11b0 <main+0x60>

LLVM IR (-O0):
@.str = [20 x i8] c"/dev/rtlightsensor0\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
store i32 0, i32* %1
store i32 256, i32* %2
%6 = load i32, i32* %2
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %4
%9 = alloca i8, i64 %7
store i64 %7, i64* %5
br label %10
10: ; preds = %23, %0
br label %11
11: ; preds = %10
%12 = call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %3
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %23
14: ; preds = %11
br label %15
15: ; preds = %20, %14
%16 = load i32, i32* %2
%17 = load i32*, i32** %3
%18 = call i32* @fgets(i8* %9, i32 %16, i32* %17)
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %9)
br label %15
22: ; preds = %15
br label %23
23: ; preds = %22, %11
%24 = load i32*, i32** %3
%25 = call i32 @fclose(i32* %24)
%26 = call i32 @usleep(i32 500000)
br label %10
}

LLVM IR (-O2):
@.str = [20 x i8] c"/dev/rtlightsensor0\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %13, %0
%4 = call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %13, label %6
6: ; preds = %3
%7 = call i32* @fgets(i8* %2, i32 256, i32* %4)
%8 = icmp eq i32* %7, null
br i1 %8, label %13, label %9
9: ; preds = %6, %9
%10 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%11 = call i32* @fgets(i8* %2, i32 256, i32* %4)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %9
13: ; preds = %9, %6, %3
%14 = call i32 @fclose(i32* %4)
%15 = call i32 @usleep(i32 500000)
br label %3
}