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

/* Variables and functions */
int /*<<< orphan*/ _led_display(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ usleep(int);
void led_test(int fd) {
  int i;
  uint8_t buf[4];
  for (i = 0; i < 8; i++) {
    memset(buf, 1 << i, 4);
    _led_display(fd, buf);
    usleep(1000 * 100);
  }
}


x86 assembly (clang, -O0):
<led_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    1188 <led_test+0x58>
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%ecx
mov    $0x1,%esi
shl    %cl,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    -0x4(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1030 <_led_display@plt>
mov    $0x186a0,%edi
call   1050 <usleep@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1142 <led_test+0x12>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<led_test>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <_led_display@plt>
mov    $0x186a0,%edi
call   1050 <usleep@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <_led_display@plt>
mov    $0x186a0,%edi
call   1050 <usleep@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <_led_display@plt>
mov    $0x186a0,%edi
call   1050 <usleep@plt>
mov    %r14,%rdi
mov    $0x8,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <_led_display@plt>
mov    $0x186a0,%edi
call   1050 <usleep@plt>
mov    %r14,%rdi
mov    $0x10,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <_led_display@plt>
mov    $0x186a0,%edi
call   1050 <usleep@plt>
mov    %r14,%rdi
mov    $0x20,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <_led_display@plt>
mov    $0x186a0,%edi
call   1050 <usleep@plt>
mov    %r14,%rdi
mov    $0x40,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <_led_display@plt>
mov    $0x186a0,%edi
call   1050 <usleep@plt>
mov    %r14,%rdi
mov    $0x80,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <_led_display@plt>
mov    $0x186a0,%edi
call   1050 <usleep@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @led_test(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [4 x i32]
store i32 %0, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %17, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 8
br i1 %7, label %8, label %20
8: ; preds = %5
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%10 = load i32, i32* %3
%11 = shl i32 1, %10
%12 = call i32 @memset(i32* %9, i32 %11, i32 4)
%13 = load i32, i32* %2
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%15 = call i32 @_led_display(i32 %13, i32* %14)
%16 = call i32 @usleep(i32 100000)
br label %17
17: ; preds = %8
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %5
20: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @led_test(i32 %0) {
%2 = alloca [4 x i32]
%3 = bitcast [4 x i32]* %2 to i8*
%4 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%5 = call i32 @memset(i32* %4, i32 1, i32 4)
%6 = call i32 @_led_display(i32 %0, i32* %4)
%7 = call i32 @usleep(i32 100000)
%8 = call i32 @memset(i32* %4, i32 2, i32 4)
%9 = call i32 @_led_display(i32 %0, i32* %4)
%10 = call i32 @usleep(i32 100000)
%11 = call i32 @memset(i32* %4, i32 4, i32 4)
%12 = call i32 @_led_display(i32 %0, i32* %4)
%13 = call i32 @usleep(i32 100000)
%14 = call i32 @memset(i32* %4, i32 8, i32 4)
%15 = call i32 @_led_display(i32 %0, i32* %4)
%16 = call i32 @usleep(i32 100000)
%17 = call i32 @memset(i32* %4, i32 16, i32 4)
%18 = call i32 @_led_display(i32 %0, i32* %4)
%19 = call i32 @usleep(i32 100000)
%20 = call i32 @memset(i32* %4, i32 32, i32 4)
%21 = call i32 @_led_display(i32 %0, i32* %4)
%22 = call i32 @usleep(i32 100000)
%23 = call i32 @memset(i32* %4, i32 64, i32 4)
%24 = call i32 @_led_display(i32 %0, i32* %4)
%25 = call i32 @usleep(i32 100000)
%26 = call i32 @memset(i32* %4, i32 128, i32 4)
%27 = call i32 @_led_display(i32 %0, i32* %4)
%28 = call i32 @usleep(i32 100000)
ret void
}