#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 EXIT_SUCCESS;
int /*<<< orphan*/ HTMLHead();
int /*<<< orphan*/ HTMLTail();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  char line[128];
  HTMLHead();
  printf("<h2> Domotics motion detector </h2>");
  FILE *motionLog = NULL;
  motionLog = fopen("motionLog.txt", "r+");
  if (motionLog != NULL) {
    while (fgets(line, 128, motionLog) != '\0') {
      printf("%s<br />", line);
    }
  } else {
    printf("<strong> Unable to open motionLog.txt file </strong>");
  }
  HTMLTail();
  fclose(motionLog);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <HTMLHead@plt>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x98(%rbp)
lea    0xe84(%rip),%rdi
lea    0xe8b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
je     1209 <main+0xa9>
jmp    11c6 <main+0x66>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rdx
mov    $0x80,%esi
call   1050 <fgets@plt>
movsbl %al,%eax
cmp    $0x0,%eax
je     1204 <main+0xa4>
lea    -0x90(%rbp),%rsi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c6 <main+0x66>
jmp    1217 <main+0xb7>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <HTMLTail@plt>
mov    -0x98(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
xor    %eax,%eax
call   1070 <HTMLHead@plt>
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9c(%rip),%rdi
lea    0xea3(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
je     11e3 <main+0x83>
mov    %rsp,%rdi
mov    $0x80,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %al,%al
je     11f1 <main+0x91>
lea    0xe7e(%rip),%r14
mov    %rsp,%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %al,%al
jne    11c0 <main+0x60>
jmp    11f1 <main+0x91>
lea    0xe54(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <HTMLTail@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    0x2dd9(%rip),%rax
mov    (%rax),%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"<h2> Domotics motion detector </h2>\00"
@.str.1 = [14 x i8] c"motionLog.txt\00"
@.str.2 = [3 x i8] c"r+\00"
@.str.3 = [9 x i8] c"%s<br />\00"
@.str.4 = [53 x i8] c"<strong> Unable to open motionLog.txt file </strong>\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [128 x i8]
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (...) @HTMLHead()
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32* null, i32** %7
%10 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %10, i32** %7
%11 = load i32*, i32** %7
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %24
13: ; preds = %2
br label %14
14: ; preds = %20, %13
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%16 = load i32*, i32** %7
%17 = call signext i8 @fgets(i8* %15, i32 128, i32* %16)
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %21)
br label %14
23: ; preds = %14
br label %26
24: ; preds = %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
br label %26
26: ; preds = %24, %23
%27 = call i32 (...) @HTMLTail()
%28 = load i32*, i32** %7
%29 = call i32 @fclose(i32* %28)
%30 = load i32, i32* @EXIT_SUCCESS
ret i32 %30
}

LLVM IR (-O2):
@.str = [36 x i8] c"<h2> Domotics motion detector </h2>\00"
@.str.1 = [14 x i8] c"motionLog.txt\00"
@.str.2 = [3 x i8] c"r+\00"
@.str.3 = [9 x i8] c"%s<br />\00"
@.str.4 = [53 x i8] c"<strong> Unable to open motionLog.txt file </strong>\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (...) @HTMLHead()
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %16, label %9
9: ; preds = %2
%10 = call signext i8 @fgets(i8* %4, i32 128, i32* %7)
%11 = icmp eq i8 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %9, %12
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%14 = call signext i8 @fgets(i8* %4, i32 128, i32* %7)
%15 = icmp eq i8 %14, 0
br i1 %15, label %18, label %12
16: ; preds = %2
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
br label %18
18: ; preds = %12, %9, %16
%19 = call i32 (...) @HTMLTail()
%20 = call i32 @fclose(i32* %7)
%21 = load i32, i32* @EXIT_SUCCESS
ret i32 %21
}