#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*/ printf(char *, ...);
scalar_t__ read_ec(int, unsigned char *);
void ec_dump() {
  unsigned char val;
  int res = 0;
  for (int i = 0; i < 256; i += 16) {
    printf("%02x: ", i);
    for (int j = 0; j < 16; j += 1) {
      res += read_ec(i + j, &val);
      printf("%02x ", (unsigned int)val);
    }
    printf("\n");
  }
  printf("%d\n", res);
}


x86 assembly (clang, -O0):
<ec_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x100,-0xc(%rbp)
jge    11bd <ec_dump+0x9d>
mov    -0xc(%rbp),%esi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x10,-0x10(%rbp)
jge    11a1 <ec_dump+0x81>
mov    -0xc(%rbp),%edi
add    -0x10(%rbp),%edi
lea    -0x1(%rbp),%rsi
call   1040 <read_ec@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
movzbl -0x1(%rbp),%esi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115b <ec_dump+0x3b>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0xc(%rbp)
jmp    1136 <ec_dump+0x16>
mov    -0x8(%rbp),%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ec_dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%r14
lea    0x7(%rsp),%r15
lea    0xeb9(%rip),%r12
xor    %r13d,%r13d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13d,%edi
mov    %r15,%rsi
call   1050 <read_ec@plt>
mov    %rax,%rbp
add    %ebx,%ebp
movzbl 0x7(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1(%r13),%edi
mov    %r15,%rsi
call   1050 <read_ec@plt>
mov    %rax,%rbx
add    %ebp,%ebx
movzbl 0x7(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x2(%r13),%edi
mov    %r15,%rsi
call   1050 <read_ec@plt>
mov    %rax,%rbp
add    %ebx,%ebp
movzbl 0x7(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x3(%r13),%edi
mov    %r15,%rsi
call   1050 <read_ec@plt>
mov    %rax,%rbx
add    %ebp,%ebx
movzbl 0x7(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%r13),%edi
mov    %r15,%rsi
call   1050 <read_ec@plt>
mov    %rax,%rbp
add    %ebx,%ebp
movzbl 0x7(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x5(%r13),%edi
mov    %r15,%rsi
call   1050 <read_ec@plt>
mov    %rax,%rbx
add    %ebp,%ebx
movzbl 0x7(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x6(%r13),%edi
mov    %r15,%rsi
call   1050 <read_ec@plt>
mov    %rax,%rbp
add    %ebx,%ebp
movzbl 0x7(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x7(%r13),%edi
mov    %r15,%rsi
call   1050 <read_ec@plt>
mov    %rax,%rbx
add    %ebp,%ebx
movzbl 0x7(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%r13),%edi
mov    %r15,%rsi
call   1050 <read_ec@plt>
mov    %rax,%rbp
add    %ebx,%ebp
movzbl 0x7(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x9(%r13),%edi
mov    %r15,%rsi
call   1050 <read_ec@plt>
mov    %rax,%rbx
add    %ebp,%ebx
movzbl 0x7(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xa(%r13),%edi
mov    %r15,%rsi
call   1050 <read_ec@plt>
mov    %rax,%rbp
add    %ebx,%ebp
movzbl 0x7(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xb(%r13),%edi
mov    %r15,%rsi
call   1050 <read_ec@plt>
mov    %rax,%rbx
add    %ebp,%ebx
movzbl 0x7(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%r13),%edi
mov    %r15,%rsi
call   1050 <read_ec@plt>
mov    %rax,%rbp
add    %ebx,%ebp
movzbl 0x7(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd(%r13),%edi
mov    %r15,%rsi
call   1050 <read_ec@plt>
mov    %rax,%rbx
add    %ebp,%ebx
movzbl 0x7(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe(%r13),%edi
mov    %r15,%rsi
call   1050 <read_ec@plt>
mov    %rax,%rbp
add    %ebx,%ebp
movzbl 0x7(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf(%r13),%edi
mov    %r15,%rsi
call   1050 <read_ec@plt>
mov    %rax,%rbx
add    %ebp,%ebx
movzbl 0x7(%rsp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x10(%r13),%eax
cmp    $0xf0,%r13d
mov    %eax,%r13d
jb     1160 <ec_dump+0x30>
lea    0xc7c(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"%02x: \00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.3 = [4 x i8] c"%d\0A\00"
define void @ec_dump() {
%1 = alloca i8
br label %4
2: ; preds = %4
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %115)
ret void
4: ; preds = %0, %4
%5 = phi i32 [ 0, %0 ], [ %120, %4 ]
%6 = phi i32 [ 0, %0 ], [ %115, %4 ]
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %5)
%8 = call i64 @read_ec(i32 %5, i8* %1)
%9 = trunc i64 %8 to i32
%10 = add i32 %6, %9
%11 = load i8, i8* %1
%12 = zext i8 %11 to i32
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = or i32 %5, 1
%15 = call i64 @read_ec(i32 %14, i8* %1)
%16 = trunc i64 %15 to i32
%17 = add i32 %10, %16
%18 = load i8, i8* %1
%19 = zext i8 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = or i32 %5, 2
%22 = call i64 @read_ec(i32 %21, i8* %1)
%23 = trunc i64 %22 to i32
%24 = add i32 %17, %23
%25 = load i8, i8* %1
%26 = zext i8 %25 to i32
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = or i32 %5, 3
%29 = call i64 @read_ec(i32 %28, i8* %1)
%30 = trunc i64 %29 to i32
%31 = add i32 %24, %30
%32 = load i8, i8* %1
%33 = zext i8 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %33)
%35 = or i32 %5, 4
%36 = call i64 @read_ec(i32 %35, i8* %1)
%37 = trunc i64 %36 to i32
%38 = add i32 %31, %37
%39 = load i8, i8* %1
%40 = zext i8 %39 to i32
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = or i32 %5, 5
%43 = call i64 @read_ec(i32 %42, i8* %1)
%44 = trunc i64 %43 to i32
%45 = add i32 %38, %44
%46 = load i8, i8* %1
%47 = zext i8 %46 to i32
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %47)
%49 = or i32 %5, 6
%50 = call i64 @read_ec(i32 %49, i8* %1)
%51 = trunc i64 %50 to i32
%52 = add i32 %45, %51
%53 = load i8, i8* %1
%54 = zext i8 %53 to i32
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %54)
%56 = or i32 %5, 7
%57 = call i64 @read_ec(i32 %56, i8* %1)
%58 = trunc i64 %57 to i32
%59 = add i32 %52, %58
%60 = load i8, i8* %1
%61 = zext i8 %60 to i32
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %61)
%63 = or i32 %5, 8
%64 = call i64 @read_ec(i32 %63, i8* %1)
%65 = trunc i64 %64 to i32
%66 = add i32 %59, %65
%67 = load i8, i8* %1
%68 = zext i8 %67 to i32
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %68)
%70 = or i32 %5, 9
%71 = call i64 @read_ec(i32 %70, i8* %1)
%72 = trunc i64 %71 to i32
%73 = add i32 %66, %72
%74 = load i8, i8* %1
%75 = zext i8 %74 to i32
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %75)
%77 = or i32 %5, 10
%78 = call i64 @read_ec(i32 %77, i8* %1)
%79 = trunc i64 %78 to i32
%80 = add i32 %73, %79
%81 = load i8, i8* %1
%82 = zext i8 %81 to i32
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %82)
%84 = or i32 %5, 11
%85 = call i64 @read_ec(i32 %84, i8* %1)
%86 = trunc i64 %85 to i32
%87 = add i32 %80, %86
%88 = load i8, i8* %1
%89 = zext i8 %88 to i32
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %89)
%91 = or i32 %5, 12
%92 = call i64 @read_ec(i32 %91, i8* %1)
%93 = trunc i64 %92 to i32
%94 = add i32 %87, %93
%95 = load i8, i8* %1
%96 = zext i8 %95 to i32
%97 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %96)
%98 = or i32 %5, 13
%99 = call i64 @read_ec(i32 %98, i8* %1)
%100 = trunc i64 %99 to i32
%101 = add i32 %94, %100
%102 = load i8, i8* %1
%103 = zext i8 %102 to i32
%104 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %103)
%105 = or i32 %5, 14
%106 = call i64 @read_ec(i32 %105, i8* %1)
%107 = trunc i64 %106 to i32
%108 = add i32 %101, %107
%109 = load i8, i8* %1
%110 = zext i8 %109 to i32
%111 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %110)
%112 = or i32 %5, 15
%113 = call i64 @read_ec(i32 %112, i8* %1)
%114 = trunc i64 %113 to i32
%115 = add i32 %108, %114
%116 = load i8, i8* %1
%117 = zext i8 %116 to i32
%118 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %117)
%119 = call i32 @putchar(i32 10)
%120 = add nuw nsw i32 %5, 16
%121 = icmp ult i32 %5, 240
br i1 %121, label %4, label %2
}