#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 jedec {
  int dummy;
};

/* Variables and functions */
int jedec_bit_get(struct jedec *, int);
int /*<<< orphan*/ printf(char *, ...);
void dump_row_asr(struct jedec *jed) {
  int i;
  printf("ASR ");
  for (i = 0; i < 20; i++) {
    int v, fuse;
    fuse = 5826 - i;
    if (i & 1)
      fuse += 2;
    v = jedec_bit_get(jed, fuse);
    printf("%c", '0' + v);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dump_row_asr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x14,-0xc(%rbp)
jge    119f <dump_row_asr+0x7f>
mov    $0x16c2,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     116e <dump_row_asr+0x4e>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <jedec_bit_get@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
add    $0x30,%esi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1141 <dump_row_asr+0x21>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_row_asr>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xec2(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %ebp,%eax
and    $0x1,%eax
lea    (%rbx,%rax,2),%esi
add    $0x16c2,%esi
mov    %r14,%rdi
call   1050 <jedec_bit_get@plt>
lea    0x30(%rax),%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
add    $0xffffffff,%ebx
cmp    $0xffffffec,%ebx
jne    1150 <dump_row_asr+0x20>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
%struct.jedec = type { i32 }
@.str = [5 x i8] c"ASR \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @dump_row_asr(%struct.jedec* %0) {
%2 = alloca %struct.jedec*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store %struct.jedec* %0, %struct.jedec** %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %7
7: ; preds = %26, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 20
br i1 %9, label %10, label %29
10: ; preds = %7
%11 = load i32, i32* %3
%12 = sub nsw i32 5826, %11
store i32 %12, i32* %5
%13 = load i32, i32* %3
%14 = and i32 %13, 1
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 2
store i32 %18, i32* %5
br label %19
19: ; preds = %16, %10
%20 = load %struct.jedec*, %struct.jedec** %2
%21 = load i32, i32* %5
%22 = call i32 @jedec_bit_get(%struct.jedec* %20, i32 %21)
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = add nsw i32 48, %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %19
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %7
29: ; preds = %7
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.jedec = type { i32 }
@.str = [5 x i8] c"ASR \00"
define void @dump_row_asr(%struct.jedec* %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %3
3: ; preds = %1, %3
%4 = phi i32 [ 0, %1 ], [ %12, %3 ]
%5 = and i32 %4, 1
%6 = icmp eq i32 %5, 0
%7 = select i1 %6, i32 5826, i32 5828
%8 = sub nuw nsw i32 %7, %4
%9 = tail call i32 @jedec_bit_get(%struct.jedec* %0, i32 %8)
%10 = add nsw i32 %9, 48
%11 = tail call i32 @putchar(i32 %10)
%12 = add nuw nsw i32 %4, 1
%13 = icmp eq i32 %12, 20
br i1 %13, label %14, label %3
14: ; preds = %3
%15 = tail call i32 @putchar(i32 10)
ret void
}