#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 */

/* Variables and functions */
int /*<<< orphan*/ clr_bit(int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ read_bit(int, int);
int /*<<< orphan*/ set_bit(int, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usleep(int);
int main(int argc, char *argv[]) {
  int x;
  if (read_bit(1, 1) < 0) {
    fprintf(stderr, "Can't access device UIO48A - Aborting\n");
    exit(1);
  }
  while (1) {
    for (x = 1; x <= 48; x++) {
      set_bit(1, x);
      usleep(50000);
      clr_bit(1, x);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%esi
mov    %esi,%edi
call   1060 <read_bit@plt>
cmp    $0x0,%rax
jge    11ab <main+0x4b>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
lea    0xe64(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    11b0 <main+0x50>
movl   $0x1,-0x14(%rbp)
cmpl   $0x30,-0x14(%rbp)
jg     11f3 <main+0x93>
mov    -0x14(%rbp),%esi
mov    $0x1,%edi
call   1040 <set_bit@plt>
mov    $0xc350,%edi
call   1080 <usleep@plt>
mov    -0x14(%rbp),%esi
mov    $0x1,%edi
call   1030 <clr_bit@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b7 <main+0x57>
jmp    11b0 <main+0x50>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x1,%edi
mov    $0x1,%esi
call   1060 <read_bit@plt>
test   %rax,%rax
js     11bc <main+0x5c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x1,%edi
mov    %ebx,%esi
call   1040 <set_bit@plt>
mov    $0xc350,%edi
call   1080 <usleep@plt>
mov    $0x1,%edi
mov    %ebx,%esi
call   1030 <clr_bit@plt>
add    $0x1,%ebx
cmp    $0x31,%ebx
jne    1190 <main+0x30>
jmp    1180 <main+0x20>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xe34(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [39 x i8] c"Can't access device UIO48A - Aborting\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i64 @read_bit(i32 1, i32 1)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
br label %14
14: ; preds = %13, %27
store i32 1, i32* %6
br label %15
15: ; preds = %24, %14
%16 = load i32, i32* %6
%17 = icmp sle i32 %16, 48
br i1 %17, label %18, label %27
18: ; preds = %15
%19 = load i32, i32* %6
%20 = call i32 @set_bit(i32 1, i32 %19)
%21 = call i32 @usleep(i32 50000)
%22 = load i32, i32* %6
%23 = call i32 @clr_bit(i32 1, i32 %22)
br label %24
24: ; preds = %18
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %15
27: ; preds = %15
br label %14
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [39 x i8] c"Can't access device UIO48A - Aborting\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @read_bit(i32 1, i32 1)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %10, %2
br label %10
10: ; preds = %9, %10
%11 = phi i32 [ 1, %9 ], [ %15, %10 ]
%12 = tail call i32 @set_bit(i32 1, i32 %11)
%13 = tail call i32 @usleep(i32 50000)
%14 = tail call i32 @clr_bit(i32 1, i32 %11)
%15 = add nuw nsw i32 %11, 1
%16 = icmp eq i32 %15, 49
br i1 %16, label %9, label %10
}