#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 EXIT_SUCCESS;
int /*<<< orphan*/ get_LED_flags(char *);
int /*<<< orphan*/ send_a_bit_out_the_LED(int, int);
int /*<<< orphan*/ set_LED_flags(char);
int main(void) {
  char message[] = "My credit card number is 4716 3164 6296 3163";
  char restore_state;
  get_LED_flags(&restore_state);
  char *p = &message[0];
  while (*p) {
    send_a_bit_out_the_LED(4, 1);
    for (int i = 0; i < 8; i++) {
      int bit_to_send = *p >> i & 0x01;
      send_a_bit_out_the_LED(4, bit_to_send);
    }
    send_a_bit_out_the_LED(4, 0);
    p++;
  }
  set_LED_flags(restore_state);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x2d,%edx
call   1050 <memcpy@plt>
lea    -0x41(%rbp),%rdi
call   1060 <get_LED_flags@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ec <main+0xac>
mov    $0x4,%edi
mov    $0x1,%esi
call   1030 <send_a_bit_out_the_LED@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x8,-0x54(%rbp)
jge    11cf <main+0x8f>
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
mov    -0x54(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%esi
mov    $0x4,%edi
call   1030 <send_a_bit_out_the_LED@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1198 <main+0x58>
mov    $0x4,%edi
xor    %esi,%esi
call   1030 <send_a_bit_out_the_LED@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    1175 <main+0x35>
movsbl -0x41(%rbp),%edi
call   1040 <set_LED_flags@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
lea    0x10(%rsp),%rbx
movups 0xedc(%rip),%xmm0
movups %xmm0,0x2d(%rsp)
movaps 0xec3(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xea7(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xf(%rsp),%rdi
call   1050 <get_LED_flags@plt>
nopl   0x0(%rax,%rax,1)
mov    $0x4,%edi
mov    $0x1,%esi
call   1030 <send_a_bit_out_the_LED@plt>
movzbl (%rbx),%esi
and    $0x1,%esi
mov    $0x4,%edi
call   1030 <send_a_bit_out_the_LED@plt>
movzbl (%rbx),%esi
shr    %esi
and    $0x1,%esi
mov    $0x4,%edi
call   1030 <send_a_bit_out_the_LED@plt>
movzbl (%rbx),%esi
shr    $0x2,%esi
and    $0x1,%esi
mov    $0x4,%edi
call   1030 <send_a_bit_out_the_LED@plt>
movzbl (%rbx),%esi
shr    $0x3,%esi
and    $0x1,%esi
mov    $0x4,%edi
call   1030 <send_a_bit_out_the_LED@plt>
movzbl (%rbx),%esi
shr    $0x4,%esi
and    $0x1,%esi
mov    $0x4,%edi
call   1030 <send_a_bit_out_the_LED@plt>
movzbl (%rbx),%esi
shr    $0x5,%esi
and    $0x1,%esi
mov    $0x4,%edi
call   1030 <send_a_bit_out_the_LED@plt>
movzbl (%rbx),%esi
shr    $0x6,%esi
and    $0x1,%esi
mov    $0x4,%edi
call   1030 <send_a_bit_out_the_LED@plt>
movzbl (%rbx),%esi
shr    $0x7,%esi
mov    $0x4,%edi
call   1030 <send_a_bit_out_the_LED@plt>
mov    $0x4,%edi
xor    %esi,%esi
call   1030 <send_a_bit_out_the_LED@plt>
cmpb   $0x0,0x1(%rbx)
lea    0x1(%rbx),%rbx
jne    1170 <main+0x40>
movsbl 0xf(%rsp),%edi
call   1040 <set_LED_flags@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.message = [45 x i8] c"My credit card number is 4716 3164 6296 3163\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [45 x i8]
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [45 x i8]* %2 to i8*
%8 = call i32 @get_LED_flags(i8* %3)
%9 = getelementptr inbounds [45 x i8], [45 x i8]* %2, i64 0, i64 0
store i8* %9, i8** %4
br label %10
10: ; preds = %31, %0
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %14, label %35
14: ; preds = %10
%15 = call i32 @send_a_bit_out_the_LED(i32 4, i32 1)
store i32 0, i32* %5
br label %16
16: ; preds = %28, %14
%17 = load i32, i32* %5
%18 = icmp slt i32 %17, 8
br i1 %18, label %19, label %31
19: ; preds = %16
%20 = load i8*, i8** %4
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = load i32, i32* %5
%24 = ashr i32 %22, %23
%25 = and i32 %24, 1
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = call i32 @send_a_bit_out_the_LED(i32 4, i32 %26)
br label %28
28: ; preds = %19
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %16
31: ; preds = %16
%32 = call i32 @send_a_bit_out_the_LED(i32 4, i32 0)
%33 = load i8*, i8** %4
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %4
br label %10
35: ; preds = %10
%36 = load i8, i8* %3
%37 = call i32 @set_LED_flags(i8 signext %36)
%38 = load i32, i32* @EXIT_SUCCESS
ret i32 %38
}

LLVM IR (-O2):
@__const.main.message = [45 x i8] c"My credit card number is 4716 3164 6296 3163\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [45 x i8]
%2 = alloca i8
%3 = getelementptr inbounds [45 x i8], [45 x i8]* %1, i64 0, i64 0
%4 = call i32 @get_LED_flags(i8* %2)
br label %5
5: ; preds = %0, %5
%6 = phi i8* [ %47, %5 ], [ %3, %0 ]
%7 = call i32 @send_a_bit_out_the_LED(i32 4, i32 1)
%8 = load i8, i8* %6
%9 = and i8 %8, 1
%10 = zext i8 %9 to i32
%11 = call i32 @send_a_bit_out_the_LED(i32 4, i32 %10)
%12 = load i8, i8* %6
%13 = lshr i8 %12, 1
%14 = and i8 %13, 1
%15 = zext i8 %14 to i32
%16 = call i32 @send_a_bit_out_the_LED(i32 4, i32 %15)
%17 = load i8, i8* %6
%18 = lshr i8 %17, 2
%19 = and i8 %18, 1
%20 = zext i8 %19 to i32
%21 = call i32 @send_a_bit_out_the_LED(i32 4, i32 %20)
%22 = load i8, i8* %6
%23 = lshr i8 %22, 3
%24 = and i8 %23, 1
%25 = zext i8 %24 to i32
%26 = call i32 @send_a_bit_out_the_LED(i32 4, i32 %25)
%27 = load i8, i8* %6
%28 = lshr i8 %27, 4
%29 = and i8 %28, 1
%30 = zext i8 %29 to i32
%31 = call i32 @send_a_bit_out_the_LED(i32 4, i32 %30)
%32 = load i8, i8* %6
%33 = lshr i8 %32, 5
%34 = and i8 %33, 1
%35 = zext i8 %34 to i32
%36 = call i32 @send_a_bit_out_the_LED(i32 4, i32 %35)
%37 = load i8, i8* %6
%38 = lshr i8 %37, 6
%39 = and i8 %38, 1
%40 = zext i8 %39 to i32
%41 = call i32 @send_a_bit_out_the_LED(i32 4, i32 %40)
%42 = load i8, i8* %6
%43 = lshr i8 %42, 7
%44 = zext i8 %43 to i32
%45 = call i32 @send_a_bit_out_the_LED(i32 4, i32 %44)
%46 = call i32 @send_a_bit_out_the_LED(i32 4, i32 0)
%47 = getelementptr inbounds i8, i8* %6, i64 1
%48 = load i8, i8* %47
%49 = icmp eq i8 %48, 0
br i1 %49, label %50, label %5
50: ; preds = %5
%51 = load i8, i8* %2
%52 = call i32 @set_LED_flags(i8 signext %51)
%53 = load i32, i32* @EXIT_SUCCESS
ret i32 %53
}