#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 uint8_t;
typedef int int8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ putchar(char);
uint8_t *GetNextCharacter(uint8_t text[], int8_t ch) {
  int i;
  printf("GETNEXTCHARACTER : Character %c ", ch);
  for (i = 7; i >= 0; i--) {
    text[i] = ch % 2;
    ch /= 2;
  }
  for (i = 0; i < 8; i++)
    printf("%d", text[i]);
  putchar('\n');
  return text;
}


x86 assembly (clang, -O0):
<GetNextCharacter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xec7(%rip),%rdi
call   1040 <printf@plt>
movl   $0x7,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     1181 <GetNextCharacter+0x61>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1145 <GetNextCharacter+0x25>
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    11b7 <GetNextCharacter+0x97>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1188 <GetNextCharacter+0x68>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetNextCharacter>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebx
mov    %rdi,0x10(%rsp)
lea    0x7f(%rbx),%eax
test   %esi,%esi
cmovns %esi,%eax
mov    %eax,0xc(%rsp)
lea    0x3f(%rbx),%r12d
test   %esi,%esi
cmovns %esi,%r12d
lea    0x1f(%rbx),%r13d
test   %esi,%esi
cmovns %esi,%r13d
lea    0xf(%rbx),%ebp
test   %esi,%esi
cmovns %esi,%ebp
lea    0x7(%rbx),%r14d
test   %esi,%esi
cmovns %esi,%r14d
lea    0x3(%rbx),%r15d
test   %esi,%esi
lea    0xe8c(%rip),%rdi
cmovns %esi,%r15d
call   1040 <printf@plt>
mov    %ebx,%eax
shr    $0x1f,%eax
add    %ebx,%eax
sar    %eax
sar    $0x2,%r15d
sar    $0x3,%r14d
movd   %r15d,%xmm0
movd   %r14d,%xmm1
punpckldq %xmm0,%xmm1
movd   %eax,%xmm0
movd   %ebx,%xmm2
punpckldq %xmm2,%xmm0
punpcklqdq %xmm0,%xmm1
movdqa %xmm1,%xmm0
psrld  $0x1f,%xmm0
paddd  %xmm1,%xmm0
psrad  $0x1,%xmm0
paddd  %xmm0,%xmm0
psubd  %xmm0,%xmm1
mov    0x10(%rsp),%rcx
movdqu %xmm1,0x10(%rcx)
mov    %ebp,%eax
sar    $0x4,%eax
shr    $0x1f,%ebp
add    %eax,%ebp
and    $0xfffffffe,%ebp
sub    %ebp,%eax
mov    %eax,0xc(%rcx)
mov    %rcx,%rbp
mov    %r13d,%eax
sar    $0x5,%eax
shr    $0x1f,%r13d
add    %eax,%r13d
and    $0xfffffffe,%r13d
sub    %r13d,%eax
mov    %eax,0x8(%rcx)
mov    %r12d,%eax
sar    $0x6,%eax
shr    $0x1f,%r12d
add    %eax,%r12d
and    $0xfffffffe,%r12d
sub    %r12d,%eax
mov    %eax,0x4(%rcx)
mov    0xc(%rsp),%eax
mov    %eax,%esi
sar    $0x7,%esi
shr    $0x1f,%eax
add    %esi,%eax
and    $0xfffffffe,%eax
sub    %eax,%esi
mov    %esi,(%rcx)
lea    0xdf2(%rip),%rbx
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0x4(%rbp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0x8(%rbp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0xc(%rbp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0x10(%rbp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0x14(%rbp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0x18(%rbp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0x1c(%rbp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbp,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"GETNEXTCHARACTER : Character %c \00"
@.str.1 = [3 x i8] c"%d\00"
define i32* @GetNextCharacter(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 7, i32* %5
br label %8
8: ; preds = %20, %2
%9 = load i32, i32* %5
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = load i32, i32* %4
%13 = srem i32 %12, 2
%14 = load i32*, i32** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
store i32 %13, i32* %17
%18 = load i32, i32* %4
%19 = sdiv i32 %18, 2
store i32 %19, i32* %4
br label %20
20: ; preds = %11
%21 = load i32, i32* %5
%22 = add nsw i32 %21, -1
store i32 %22, i32* %5
br label %8
23: ; preds = %8
store i32 0, i32* %5
br label %24
24: ; preds = %34, %23
%25 = load i32, i32* %5
%26 = icmp slt i32 %25, 8
br i1 %26, label %27, label %37
27: ; preds = %24
%28 = load i32*, i32** %3
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
%32 = load i32, i32* %31
%33 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %27
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %24
37: ; preds = %24
%38 = call i32 @putchar(i8 signext 10)
%39 = load i32*, i32** %3
ret i32* %39
}

LLVM IR (-O2):
@.str = [33 x i8] c"GETNEXTCHARACTER : Character %c \00"
@.str.1 = [3 x i8] c"%d\00"
define i32* @GetNextCharacter(i32* returned %0, i32 %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %1)
%4 = getelementptr inbounds i32, i32* %0, i64 7
%5 = sdiv i32 %1, 2
%6 = getelementptr inbounds i32, i32* %0, i64 6
%7 = sdiv i32 %1, 4
%8 = getelementptr inbounds i32, i32* %0, i64 5
%9 = sdiv i32 %1, 8
%10 = insertelement <4 x i32> poison, i32 %1, i64 3
%11 = insertelement <4 x i32> %10, i32 %9, i64 0
%12 = insertelement <4 x i32> %11, i32 %7, i64 1
%13 = insertelement <4 x i32> %12, i32 %5, i64 2
%14 = srem <4 x i32> %13, <i32 2, i32 2, i32 2, i32 2>
%15 = getelementptr inbounds i32, i32* %0, i64 4
%16 = bitcast i32* %15 to <4 x i32>*
store <4 x i32> %14, <4 x i32>* %16
%17 = sdiv i32 %1, 16
%18 = srem i32 %17, 2
%19 = getelementptr inbounds i32, i32* %0, i64 3
store i32 %18, i32* %19
%20 = sdiv i32 %1, 32
%21 = srem i32 %20, 2
%22 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %21, i32* %22
%23 = sdiv i32 %1, 64
%24 = srem i32 %23, 2
%25 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %24, i32* %25
%26 = sdiv i32 %1, 128
%27 = srem i32 %26, 2
store i32 %27, i32* %0
%28 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %25
%30 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %22
%32 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %19
%34 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %15
%36 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %8
%38 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %6
%40 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %4
%42 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %41)
%43 = tail call i32 @putchar(i8 signext 10)
ret i32* %0
}