#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 timespec {
  int tv_nsec;
  int /*<<< orphan*/ tv_sec;
};
struct sched_param {
  int sched_priority;
};

/* Variables and functions */
int O_NDELAY;
int O_WRONLY;
int /*<<< orphan*/ SCHED_FIFO;
int /*<<< orphan*/ TIMER_ABSTIME;
int atoi(char *);
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int clock_nanosleep(int /*<<< orphan*/, int /*<<< orphan*/, struct timespec *,
                    int /*<<< orphan*/ *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int open(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int sched_setscheduler(int /*<<< orphan*/, int /*<<< orphan*/,
                       struct sched_param *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ tsnorm(struct timespec *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  struct timespec t, u;
  struct sched_param param;
  int interval = 50000000;
  int retValSleep;
  int fd;
  char zero_string[] = "0";
  char one_string[] = "1";
  char buffer[52];
  unsigned char value = 0;
  {
    if ((fd = open("/sys/class/gpio/export", O_WRONLY | O_NDELAY, 0)) == 0) {
      printf("Error: Can't open /sys/class/gpio/export.\n");
      exit(1);
    }
    strcpy(buffer, "41");
    write(fd, buffer, strlen(buffer));
    close(fd);
    printf("Added GPIO 41.\n");
  }
  {
    if ((fd = open("/sys/class/gpio/gpio41/direction", O_WRONLY | O_NDELAY,
                   0)) == 0) {
      printf("Error: Can't open /sys/class/gpio/gpio41/direction.\n");
      exit(1);
    }
    strcpy(buffer, "out");
    write(fd, buffer, strlen(buffer));
    close(fd);
    printf("Direction set to out.\n");
  }
  {
    if ((fd = open("/sys/class/gpio/gpio41/value", O_WRONLY | O_NDELAY, 0)) ==
        0) {
      printf("Error: Can't open /sys/class/gpio/gpio41/value.\n");
      exit(1);
    }
    printf("Value opened for writing.\n");
  }
  if (argc >= 2 && atoi(argv[1]) > 0) {
    printf("Using realtime, priority: %d.\n", atoi(argv[1]));
    param.sched_priority = atoi(argv[1]);
    if (sched_setscheduler(0, SCHED_FIFO, &param) == -1) {
      perror("Error: sched_setscheduler failed.");
      exit(-1);
    }
  }
  if (argc >= 3)
    interval = atoi(argv[2]);
  clock_gettime(0, &t);
  t.tv_sec++;
  while (1) {
    retValSleep = clock_nanosleep(0, TIMER_ABSTIME, &t, NULL);
    if (value) {
      write(fd, one_string, 1);
    } else {
      write(fd, zero_string, 1);
    }
    value = !value;
    t.tv_nsec += interval;
    tsnorm(&t);
  }
  return 0;
}


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)
movl   $0x2faf080,-0x2c(%rbp)
mov    0xe09(%rip),%ax
mov    %ax,-0x36(%rbp)
mov    0xe43(%rip),%ax
mov    %ax,-0x38(%rbp)
movb   $0x0,-0x71(%rbp)
mov    0x2daf(%rip),%rax
mov    (%rax),%esi
mov    0x2db6(%rip),%rax
or     (%rax),%esi
lea    0xddf(%rip),%rdi
xor    %edx,%edx
call   10b0 <open@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jne    124e <main+0x7e>
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    -0x70(%rbp),%rdi
lea    0xdeb(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x84(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x80(%rbp)
lea    -0x70(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x84(%rbp),%edi
mov    -0x80(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    -0x34(%rbp),%edi
call   1090 <close@plt>
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2d1a(%rip),%rax
mov    (%rax),%esi
mov    0x2d21(%rip),%rax
or     (%rax),%esi
lea    0xd9f(%rip),%rdi
xor    %edx,%edx
call   10b0 <open@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jne    12e3 <main+0x113>
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    -0x70(%rbp),%rdi
lea    0xdbf(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x94(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x90(%rbp)
lea    -0x70(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x94(%rbp),%edi
mov    -0x90(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    -0x34(%rbp),%edi
call   1090 <close@plt>
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2c7f(%rip),%rax
mov    (%rax),%esi
mov    0x2c86(%rip),%rax
or     (%rax),%esi
lea    0xd75(%rip),%rdi
xor    %edx,%edx
call   10b0 <open@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jne    137e <main+0x1ae>
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0xd91(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
jl     1411 <main+0x241>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10d0 <atoi@plt>
cmp    $0x0,%eax
jle    1411 <main+0x241>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,%esi
lea    0xd6f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x28(%rbp)
mov    0x2c00(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x28(%rbp),%rdx
call   1080 <sched_setscheduler@plt>
cmp    $0xffffffff,%eax
jne    140c <main+0x23c>
lea    0xd53(%rip),%rdi
call   10c0 <perror@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
jmp    1411 <main+0x241>
cmpl   $0x3,-0x8(%rbp)
jl     142b <main+0x25b>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x2c(%rbp)
xor    %edi,%edi
lea    -0x18(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    0x2ba2(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   10f0 <clock_nanosleep@plt>
mov    %eax,-0x30(%rbp)
cmpb   $0x0,-0x71(%rbp)
je     147a <main+0x2aa>
mov    -0x34(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
jmp    148b <main+0x2bb>
mov    -0x34(%rbp),%edi
lea    -0x36(%rbp),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
cmpb   $0x0,-0x71(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x71(%rbp)
mov    -0x2c(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
call   10a0 <tsnorm@plt>
jmp    143f <main+0x26f>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
movw   $0x30,0xe(%rsp)
movw   $0x31,0xc(%rsp)
mov    0x2db7(%rip),%r12
mov    0x2dc0(%rip),%r13
mov    0x0(%r13),%esi
or     (%r12),%esi
lea    0xde1(%rip),%rdi
xor    %edx,%edx
call   10c0 <open@plt>
test   %eax,%eax
je     13bf <main+0x1df>
mov    %eax,%ebx
lea    0xde0(%rip),%rsi
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
call   1070 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
mov    %ebx,%edi
call   10a0 <close@plt>
lea    0xe37(%rip),%rdi
call   1040 <puts@plt>
mov    0x0(%r13),%esi
or     (%r12),%esi
lea    0xda0(%rip),%rdi
xor    %edx,%edx
call   10c0 <open@plt>
test   %eax,%eax
je     13c8 <main+0x1e8>
mov    %eax,%ebx
lea    0xda9(%rip),%rsi
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
call   1070 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
mov    %ebx,%edi
call   10a0 <close@plt>
lea    0xdeb(%rip),%rdi
call   1040 <puts@plt>
mov    0x0(%r13),%esi
or     (%r12),%esi
lea    0xd6a(%rip),%rdi
xor    %edx,%edx
call   10c0 <open@plt>
test   %eax,%eax
je     13d1 <main+0x1f1>
mov    %eax,%r13d
lea    0xdd4(%rip),%rdi
call   1040 <puts@plt>
mov    $0x2faf080,%ebp
cmp    $0x2,%r15d
jl     1357 <main+0x177>
mov    0x8(%r14),%rdi
call   10e0 <atoi@plt>
test   %eax,%eax
jle    1346 <main+0x166>
lea    0xd4a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x8(%r14),%rdi
call   10e0 <atoi@plt>
mov    %eax,0x10(%rsp)
mov    0x2cb1(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
xor    %edi,%edi
call   1090 <sched_setscheduler@plt>
cmp    $0xffffffff,%eax
je     13e7 <main+0x207>
cmp    $0x3,%r15d
jb     1357 <main+0x177>
mov    0x10(%r14),%rdi
call   10e0 <atoi@plt>
mov    %eax,%ebp
mov    %ebp,%r14d
xor    %ebp,%ebp
lea    0x18(%rsp),%rbx
xor    %edi,%edi
mov    %rbx,%rsi
call   1050 <clock_gettime@plt>
addl   $0x1,0x1c(%rsp)
lea    0xe(%rsp),%r15
lea    0xc(%rsp),%r12
nopw   0x0(%rax,%rax,1)
mov    0x2c61(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1100 <clock_nanosleep@plt>
test   %bpl,%bpl
mov    %r12,%rsi
cmove  %r15,%rsi
mov    %r13d,%edi
mov    $0x1,%edx
call   1060 <write@plt>
xor    $0x1,%bpl
add    %r14d,0x18(%rsp)
mov    %rbx,%rdi
call   10b0 <tsnorm@plt>
jmp    1380 <main+0x1a0>
lea    0xd7a(%rip),%rdi
jmp    13d8 <main+0x1f8>
lea    0xd3d(%rip),%rdi
jmp    13d8 <main+0x1f8>
lea    0xd04(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    0xc8d(%rip),%rdi
call   10d0 <perror@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
%struct.sched_param = type { i32 }
@__const.main.zero_string = [2 x i8] c"0\00"
@__const.main.one_string = [2 x i8] c"1\00"
@.str = [23 x i8] c"/sys/class/gpio/export\00"
@O_WRONLY = global i32 0
@O_NDELAY = global i32 0
@.str.1 = [43 x i8] c"Error: Can't open /sys/class/gpio/export.\0A\00"
@.str.2 = [3 x i8] c"41\00"
@.str.3 = [16 x i8] c"Added GPIO 41.\0A\00"
@.str.4 = [33 x i8] c"/sys/class/gpio/gpio41/direction\00"
@.str.5 = [53 x i8] c"Error: Can't open /sys/class/gpio/gpio41/direction.\0A\00"
@.str.6 = [4 x i8] c"out\00"
@.str.7 = [23 x i8] c"Direction set to out.\0A\00"
@.str.8 = [29 x i8] c"/sys/class/gpio/gpio41/value\00"
@.str.9 = [49 x i8] c"Error: Can't open /sys/class/gpio/gpio41/value.\0A\00"
@.str.10 = [27 x i8] c"Value opened for writing.\0A\00"
@.str.11 = [31 x i8] c"Using realtime, priority: %d.\0A\00"
@SCHED_FIFO = global i32 0
@.str.12 = [34 x i8] c"Error: sched_setscheduler failed.\00"
@TIMER_ABSTIME = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timespec
%7 = alloca %struct.timespec
%8 = alloca %struct.sched_param
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [2 x i8]
%13 = alloca [2 x i8]
%14 = alloca [52 x i8]
%15 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 50000000, i32* %9
%16 = bitcast [2 x i8]* %12 to i8*
%17 = bitcast [2 x i8]* %13 to i8*
store i8 0, i8* %15
%18 = load i32, i32* @O_WRONLY
%19 = load i32, i32* @O_NDELAY
%20 = or i32 %18, %19
%21 = call i32 @open(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %20, i32 0)
store i32 %21, i32* %11
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %2
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = getelementptr inbounds [52 x i8], [52 x i8]* %14, i64 0, i64 0
%28 = call i32 @strcpy(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%29 = load i32, i32* %11
%30 = getelementptr inbounds [52 x i8], [52 x i8]* %14, i64 0, i64 0
%31 = getelementptr inbounds [52 x i8], [52 x i8]* %14, i64 0, i64 0
%32 = call i32 @strlen(i8* %31)
%33 = call i32 @write(i32 %29, i8* %30, i32 %32)
%34 = load i32, i32* %11
%35 = call i32 @close(i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%37 = load i32, i32* @O_WRONLY
%38 = load i32, i32* @O_NDELAY
%39 = or i32 %37, %38
%40 = call i32 @open(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %39, i32 0)
store i32 %40, i32* %11
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %26
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %26
%46 = getelementptr inbounds [52 x i8], [52 x i8]* %14, i64 0, i64 0
%47 = call i32 @strcpy(i8* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%48 = load i32, i32* %11
%49 = getelementptr inbounds [52 x i8], [52 x i8]* %14, i64 0, i64 0
%50 = getelementptr inbounds [52 x i8], [52 x i8]* %14, i64 0, i64 0
%51 = call i32 @strlen(i8* %50)
%52 = call i32 @write(i32 %48, i8* %49, i32 %51)
%53 = load i32, i32* %11
%54 = call i32 @close(i32 %53)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%56 = load i32, i32* @O_WRONLY
%57 = load i32, i32* @O_NDELAY
%58 = or i32 %56, %57
%59 = call i32 @open(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %58, i32 0)
store i32 %59, i32* %11
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %45
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.9, i64 0, i64 0))
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %45
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%66 = load i32, i32* %4
%67 = icmp sge i32 %66, 2
br i1 %67, label %68, label %92
68: ; preds = %64
%69 = load i8**, i8*** %5
%70 = getelementptr inbounds i8*, i8** %69, i64 1
%71 = load i8*, i8** %70
%72 = call i32 @atoi(i8* %71)
%73 = icmp sgt i32 %72, 0
br i1 %73, label %74, label %92
74: ; preds = %68
%75 = load i8**, i8*** %5
%76 = getelementptr inbounds i8*, i8** %75, i64 1
%77 = load i8*, i8** %76
%78 = call i32 @atoi(i8* %77)
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0), i32 %78)
%80 = load i8**, i8*** %5
%81 = getelementptr inbounds i8*, i8** %80, i64 1
%82 = load i8*, i8** %81
%83 = call i32 @atoi(i8* %82)
%84 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %8, i32 0, i32 0
store i32 %83, i32* %84
%85 = load i32, i32* @SCHED_FIFO
%86 = call i32 @sched_setscheduler(i32 0, i32 %85, %struct.sched_param* %8)
%87 = icmp eq i32 %86, -1
br i1 %87, label %88, label %91
88: ; preds = %74
%89 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.12, i64 0, i64 0))
%90 = call i32 @exit(i32 -1)
unreachable
91: ; preds = %74
br label %92
92: ; preds = %91, %68, %64
%93 = load i32, i32* %4
%94 = icmp sge i32 %93, 3
br i1 %94, label %95, label %100
95: ; preds = %92
%96 = load i8**, i8*** %5
%97 = getelementptr inbounds i8*, i8** %96, i64 2
%98 = load i8*, i8** %97
%99 = call i32 @atoi(i8* %98)
store i32 %99, i32* %9
br label %100
100: ; preds = %95, %92
%101 = call i32 @clock_gettime(i32 0, %struct.timespec* %6)
%102 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 1
%103 = load i32, i32* %102
%104 = add nsw i32 %103, 1
store i32 %104, i32* %102
br label %105
105: ; preds = %100, %118
%106 = load i32, i32* @TIMER_ABSTIME
%107 = call i32 @clock_nanosleep(i32 0, i32 %106, %struct.timespec* %6, i32* null)
store i32 %107, i32* %10
%108 = load i8, i8* %15
%109 = icmp ne i8 %108, 0
br i1 %109, label %110, label %114
110: ; preds = %105
%111 = load i32, i32* %11
%112 = getelementptr inbounds [2 x i8], [2 x i8]* %13, i64 0, i64 0
%113 = call i32 @write(i32 %111, i8* %112, i32 1)
br label %118
114: ; preds = %105
%115 = load i32, i32* %11
%116 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%117 = call i32 @write(i32 %115, i8* %116, i32 1)
br label %118
118: ; preds = %114, %110
%119 = load i8, i8* %15
%120 = icmp ne i8 %119, 0
%121 = xor i1 %120, true
%122 = zext i1 %121 to i32
%123 = trunc i32 %122 to i8
store i8 %123, i8* %15
%124 = load i32, i32* %9
%125 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
%126 = load i32, i32* %125
%127 = add nsw i32 %126, %124
store i32 %127, i32* %125
%128 = call i32 @tsnorm(%struct.timespec* %6)
br label %105
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
%struct.sched_param = type { i32 }
@.str = [23 x i8] c"/sys/class/gpio/export\00"
@O_WRONLY = global i32 0
@O_NDELAY = global i32 0
@.str.2 = [3 x i8] c"41\00"
@.str.4 = [33 x i8] c"/sys/class/gpio/gpio41/direction\00"
@.str.6 = [4 x i8] c"out\00"
@.str.8 = [29 x i8] c"/sys/class/gpio/gpio41/value\00"
@.str.11 = [31 x i8] c"Using realtime, priority: %d.\0A\00"
@SCHED_FIFO = global i32 0
@.str.12 = [34 x i8] c"Error: sched_setscheduler failed.\00"
@TIMER_ABSTIME = global i32 0
@str = [15 x i8] c"Added GPIO 41.\00"
@str.13 = [22 x i8] c"Direction set to out.\00"
@str.14 = [26 x i8] c"Value opened for writing.\00"
@str.15 = [48 x i8] c"Error: Can't open /sys/class/gpio/gpio41/value.\00"
@str.16 = [52 x i8] c"Error: Can't open /sys/class/gpio/gpio41/direction.\00"
@str.17 = [42 x i8] c"Error: Can't open /sys/class/gpio/export.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timespec
%4 = alloca %struct.sched_param
%5 = alloca i16
%6 = alloca i16
%7 = alloca [52 x i8]
%8 = bitcast %struct.timespec* %3 to i8*
%9 = bitcast %struct.sched_param* %4 to i8*
%10 = bitcast i16* %5 to i8*
store i16 48, i16* %5
%11 = bitcast i16* %6 to i8*
store i16 49, i16* %6
%12 = getelementptr inbounds [52 x i8], [52 x i8]* %7, i64 0, i64 0
%13 = load i32, i32* @O_WRONLY
%14 = load i32, i32* @O_NDELAY
%15 = or i32 %14, %13
%16 = tail call i32 @open(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %15, i32 0)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.17, i64 0, i64 0))
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @strlen(i8* %12)
%24 = call i32 @write(i32 %16, i8* %12, i32 %23)
%25 = call i32 @close(i32 %16)
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%27 = load i32, i32* @O_WRONLY
%28 = load i32, i32* @O_NDELAY
%29 = or i32 %28, %27
%30 = call i32 @open(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %29, i32 0)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %21
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.16, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %21
%36 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%37 = call i32 @strlen(i8* %12)
%38 = call i32 @write(i32 %30, i8* %12, i32 %37)
%39 = call i32 @close(i32 %30)
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.13, i64 0, i64 0))
%41 = load i32, i32* @O_WRONLY
%42 = load i32, i32* @O_NDELAY
%43 = or i32 %42, %41
%44 = call i32 @open(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i32 %43, i32 0)
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %35
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.15, i64 0, i64 0))
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %35
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.14, i64 0, i64 0))
%51 = icmp sgt i32 %0, 1
br i1 %51, label %52, label %74
52: ; preds = %49
%53 = getelementptr inbounds i8*, i8** %1, i64 1
%54 = load i8*, i8** %53
%55 = call i32 @atoi(i8* %54)
%56 = icmp sgt i32 %55, 0
br i1 %56, label %57, label %68
57: ; preds = %52
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0), i32 %55)
%59 = load i8*, i8** %53
%60 = call i32 @atoi(i8* %59)
%61 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %4, i64 0, i32 0
store i32 %60, i32* %61
%62 = load i32, i32* @SCHED_FIFO
%63 = call i32 @sched_setscheduler(i32 0, i32 %62, %struct.sched_param* %4)
%64 = icmp eq i32 %63, -1
br i1 %64, label %65, label %68
65: ; preds = %57
%66 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.12, i64 0, i64 0))
%67 = call i32 @exit(i32 -1)
unreachable
68: ; preds = %57, %52
%69 = icmp ugt i32 %0, 2
br i1 %69, label %70, label %74
70: ; preds = %68
%71 = getelementptr inbounds i8*, i8** %1, i64 2
%72 = load i8*, i8** %71
%73 = call i32 @atoi(i8* %72)
br label %74
74: ; preds = %49, %70, %68
%75 = phi i32 [ %73, %70 ], [ 50000000, %68 ], [ 50000000, %49 ]
%76 = call i32 @clock_gettime(i32 0, %struct.timespec* %3)
%77 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
%78 = load i32, i32* %77
%79 = add nsw i32 %78, 1
store i32 %79, i32* %77
%80 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
br label %81
81: ; preds = %81, %74
%82 = phi i8 [ 0, %74 ], [ %88, %81 ]
%83 = load i32, i32* @TIMER_ABSTIME
%84 = call i32 @clock_nanosleep(i32 0, i32 %83, %struct.timespec* %3, i32* null)
%85 = icmp eq i8 %82, 0
%86 = select i1 %85, i8* %10, i8* %11
%87 = call i32 @write(i32 %44, i8* %86, i32 1)
%88 = xor i8 %82, 1
%89 = load i32, i32* %80
%90 = add nsw i32 %89, %75
store i32 %90, i32* %80
%91 = call i32 @tsnorm(%struct.timespec* %3)
br label %81
}