#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 */
struct ProcState_s {
  int dummy;
};

/* Variables and functions */
char *now();
int /*<<< orphan*/ printf(char *, char *, char *, int, char *);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write(int, char *, int);
void *Watchdog(struct ProcState_s *PState) {
  int fd_led = 0;
  {
    printf("%s : LOG %s %d %s", now(),
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/golding/Josefin/refs/heads/master/"
           "Watchdog.c",
           42, "Started\n");
  };
  while (1) {
    write(fd_led, "1", 1);
    usleep(500000);
    write(fd_led, "0", 1);
    usleep(500000);
  }
}


x86 assembly (clang, -O0):
<Watchdog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1050 <now@plt>
mov    %rax,%rsi
lea    0xe9c(%rip),%rdi
lea    0xea7(%rip),%rdx
mov    $0x2a,%ecx
lea    0xf22(%rip),%r8
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
lea    0xf1c(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
mov    -0xc(%rbp),%edi
lea    0xf00(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
jmp    117c <Watchdog+0x3c>

x86 assembly (clang, -O2):
<Watchdog>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <now@plt>
lea    0xeae(%rip),%rdi
lea    0xeb9(%rip),%rdx
lea    0xf39(%rip),%r8
mov    %rax,%rsi
mov    $0x2a,%ecx
call   1040 <printf@plt>
lea    0xf2e(%rip),%r14
lea    0xf29(%rip),%rbx
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x7a120,%edi
call   1060 <usleep@plt>
jmp    1180 <Watchdog+0x40>

LLVM IR (-O0):
%struct.ProcState_s = type { i32 }
@.str = [18 x i8] c"%s : LOG %s %d %s\00"
@.str.1 = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/golding/Josefin/refs/heads/master/Watchdog.c\00"
@.str.2 = [9 x i8] c"Started\0A\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [2 x i8] c"0\00"
define i8* @Watchdog(%struct.ProcState_s* %0) {
%2 = alloca %struct.ProcState_s*
%3 = alloca i32
store %struct.ProcState_s* %0, %struct.ProcState_s** %2
store i32 0, i32* %3
%4 = call i8* (...) @now()
%5 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 42, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %6
6: ; preds = %1, %6
%7 = load i32, i32* %3
%8 = call i32 @write(i32 %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%9 = call i32 @usleep(i32 500000)
%10 = load i32, i32* %3
%11 = call i32 @write(i32 %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
%12 = call i32 @usleep(i32 500000)
br label %6
}

LLVM IR (-O2):
%struct.ProcState_s = type { i32 }
@.str = [18 x i8] c"%s : LOG %s %d %s\00"
@.str.1 = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/golding/Josefin/refs/heads/master/Watchdog.c\00"
@.str.2 = [9 x i8] c"Started\0A\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [2 x i8] c"0\00"
define noalias i8* @Watchdog(%struct.ProcState_s* nocapture readnone %0) {
%2 = tail call i8* (...) @now()
%3 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 42, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %4
4: ; preds = %4, %1
%5 = tail call i32 @write(i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%6 = tail call i32 @usleep(i32 500000)
%7 = tail call i32 @write(i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
%8 = tail call i32 @usleep(i32 500000)
br label %4
}