#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*/ time_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_FAILURE;
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  FILE *fp;
  time_t tm;
  fp = fopen("/dev/ttyAMA0", "w");
  while (1) {
    time(&tm);
    fprintf(fp, "%s", ctime(&tm));
    fflush(fp);
    sleep(1);
  }
  return EXIT_FAILURE;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   1050 <time@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x14(%rbp),%rdi
call   1030 <ctime@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rdx
lea    0xe61(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <fflush@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
jmp    1186 <main+0x26>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xe95(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0x4(%rsp),%r14
nop
mov    %r14,%rdi
call   1050 <time@plt>
mov    %r14,%rdi
call   1030 <ctime@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <fputs@plt>
mov    %rbx,%rdi
call   1060 <fflush@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
jmp    1180 <main+0x20>

LLVM IR (-O0):
@.str = [13 x i8] c"/dev/ttyAMA0\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"%s\00"
@EXIT_FAILURE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
br label %5
5: ; preds = %0, %5
%6 = call i32 @time(i32* %3)
%7 = load i32*, i32** %2
%8 = call i8* @ctime(i32* %3)
%9 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = load i32*, i32** %2
%11 = call i32 @fflush(i32* %10)
%12 = call i32 @sleep(i32 1)
br label %5
}

LLVM IR (-O2):
@.str = [13 x i8] c"/dev/ttyAMA0\00"
@.str.1 = [2 x i8] c"w\00"
@EXIT_FAILURE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %4
4: ; preds = %4, %0
%5 = call i32 @time(i32* %1)
%6 = call i8* @ctime(i32* %1)
%7 = call i32 @fputs(i8* %6, i32* %3)
%8 = call i32 @fflush(i32* %3)
%9 = call i32 @sleep(i32 1)
br label %4
}