#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 */
char *ec_point_format_name(unsigned int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned int);
int /*<<< orphan*/ printf(char *, ...);
unsigned int read_uint(char *, unsigned int, int);
int /*<<< orphan*/ stderr;
void parse_point_formats(char *data, unsigned offset, unsigned length,
                         int json) {
  unsigned pos = offset;
  unsigned point_formats_length = read_uint(data, pos, 1);
  unsigned point_format_code;
  const char *name = NULL;
  int i = 0;
  pos += 1;
  if (json)
    printf("\"point_format_list\": [");
  for (; pos < offset + length; pos += 1) {
    if (json && i != 0)
      printf(", ");
    point_format_code = read_uint(data, pos, 1);
    name = ec_point_format_name(point_format_code);
    if (name == NULL) {
      name = "unknown";
      fprintf(stderr, "WARNING! Unknown point format (%#.02x)\n",
              point_format_code);
    }
    if (json)
      printf("{\"name\": \"%s\", \"id\": \"%#.02x\"}", name, point_format_code);
    else
      printf("\t\t%s\n", name);
    i++;
  }
  if (json)
    printf("]");
}


x86 assembly (clang, -O0):
<parse_point_formats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    $0x1,%edx
call   1050 <read_uint@plt>
mov    %eax,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     119f <parse_point_formats+0x5f>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a4 <parse_point_formats+0x64>
mov    -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jae    1272 <parse_point_formats+0x132>
cmpl   $0x0,-0x14(%rbp)
je     11d7 <parse_point_formats+0x97>
cmpl   $0x0,-0x2c(%rbp)
je     11d7 <parse_point_formats+0x97>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    $0x1,%edx
call   1050 <read_uint@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
call   1060 <ec_point_format_name@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1225 <parse_point_formats+0xe5>
lea    0xe11(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
lea    0xe02(%rip),%rsi
call   1040 <fprintf@plt>
cmpl   $0x0,-0x14(%rbp)
je     1249 <parse_point_formats+0x109>
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%edx
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125b <parse_point_formats+0x11b>
mov    -0x28(%rbp),%rsi
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a4 <parse_point_formats+0x64>
cmpl   $0x0,-0x14(%rbp)
je     128a <parse_point_formats+0x14a>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_point_formats>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,(%rsp)
mov    $0x1,%edx
call   1060 <read_uint@plt>
test   %ebx,%ebx
je     1183 <parse_point_formats+0x33>
lea    0xe84(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%r14,%r15,1),%eax
add    $0x1,%r15d
cmp    %eax,%r15d
jae    1240 <parse_point_formats+0xf0>
add    $0xffffffff,%r14d
xor    %r12d,%r12d
jmp    11be <parse_point_formats+0x6e>
nopl   (%rax)
lea    0xec2(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12d
cmp    %r12d,%r14d
je     1240 <parse_point_formats+0xf0>
lea    (%r15,%r12,1),%ebp
test   %ebx,%ebx
je     11d9 <parse_point_formats+0x89>
test   %r12d,%r12d
je     11d9 <parse_point_formats+0x89>
lea    0xe45(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1060 <read_uint@plt>
mov    %eax,%r13d
mov    %eax,%edi
call   1070 <ec_point_format_name@plt>
test   %rax,%rax
je     1200 <parse_point_formats+0xb0>
test   %ebx,%ebx
jne    1227 <parse_point_formats+0xd7>
jmp    11a0 <parse_point_formats+0x50>
xchg   %ax,%ax
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
lea    0xe12(%rip),%rsi
mov    %r13d,%edx
call   1050 <fprintf@plt>
lea    0xdfb(%rip),%rax
test   %ebx,%ebx
je     11a0 <parse_point_formats+0x50>
lea    0xe1c(%rip),%rdi
mov    %rax,%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11b1 <parse_point_formats+0x61>
test   %ebx,%ebx
je     125c <parse_point_formats+0x10c>
mov    $0x5d,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\22point_format_list\22: [\00"
@.str.1 = [3 x i8] c", \00"
@.str.2 = [8 x i8] c"unknown\00"
@stderr = global i32 0
@.str.3 = [40 x i8] c"WARNING! Unknown point format (%#.02x)\0A\00"
@.str.4 = [31 x i8] c"{\22name\22: \22%s\22, \22id\22: \22%#.02x\22}\00"
@.str.5 = [6 x i8] c"\09\09%s\0A\00"
@.str.6 = [2 x i8] c"]\00"
define void @parse_point_formats(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%14 = load i32, i32* %6
store i32 %14, i32* %9
%15 = load i8*, i8** %5
%16 = load i32, i32* %9
%17 = call i32 @read_uint(i8* %15, i32 %16, i32 1)
store i32 %17, i32* %10
store i8* null, i8** %12
store i32 0, i32* %13
%18 = load i32, i32* %9
%19 = add i32 %18, 1
store i32 %19, i32* %9
%20 = load i32, i32* %8
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %4
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %4
br label %25
25: ; preds = %64, %24
%26 = load i32, i32* %9
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = add i32 %27, %28
%30 = icmp ult i32 %26, %29
br i1 %30, label %31, label %67
31: ; preds = %25
%32 = load i32, i32* %8
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = load i32, i32* %13
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %37, %34, %31
%40 = load i8*, i8** %5
%41 = load i32, i32* %9
%42 = call i32 @read_uint(i8* %40, i32 %41, i32 1)
store i32 %42, i32* %11
%43 = load i32, i32* %11
%44 = call i8* @ec_point_format_name(i32 %43)
store i8* %44, i8** %12
%45 = load i8*, i8** %12
%46 = icmp eq i8* %45, null
br i1 %46, label %47, label %51
47: ; preds = %39
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %12
%48 = load i32, i32* @stderr
%49 = load i32, i32* %11
%50 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %47, %39
%52 = load i32, i32* %8
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %51
%55 = load i8*, i8** %12
%56 = load i32, i32* %11
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %55, i32 %56)
br label %61
58: ; preds = %51
%59 = load i8*, i8** %12
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %59)
br label %61
61: ; preds = %58, %54
%62 = load i32, i32* %13
%63 = add nsw i32 %62, 1
store i32 %63, i32* %13
br label %64
64: ; preds = %61
%65 = load i32, i32* %9
%66 = add i32 %65, 1
store i32 %66, i32* %9
br label %25
67: ; preds = %25
%68 = load i32, i32* %8
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %72
70: ; preds = %67
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %72
72: ; preds = %70, %67
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"\22point_format_list\22: [\00"
@.str.1 = [3 x i8] c", \00"
@.str.2 = [8 x i8] c"unknown\00"
@stderr = global i32 0
@.str.3 = [40 x i8] c"WARNING! Unknown point format (%#.02x)\0A\00"
@.str.4 = [31 x i8] c"{\22name\22: \22%s\22, \22id\22: \22%#.02x\22}\00"
@.str.5 = [6 x i8] c"\09\09%s\0A\00"
define void @parse_point_formats(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @read_uint(i8* %0, i32 %1, i32 1)
%6 = icmp ne i32 %3, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %4
%10 = add i32 %2, %1
%11 = add i32 %1, 1
%12 = icmp ult i32 %11, %10
br i1 %12, label %13, label %39
13: ; preds = %9
%14 = add i32 %2, -1
br label %15
15: ; preds = %13, %35
%16 = phi i32 [ %37, %35 ], [ %11, %13 ]
%17 = phi i32 [ %36, %35 ], [ 0, %13 ]
%18 = icmp ne i32 %17, 0
%19 = select i1 %6, i1 %18, i1 false
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %15
%23 = tail call i32 @read_uint(i8* %0, i32 %16, i32 1)
%24 = tail call i8* @ec_point_format_name(i32 %23)
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %23)
br label %29
29: ; preds = %26, %22
%30 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), %26 ], [ %24, %22 ]
br i1 %6, label %31, label %33
31: ; preds = %29
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %30, i32 %23)
br label %35
33: ; preds = %29
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %30)
br label %35
35: ; preds = %33, %31
%36 = add nuw i32 %17, 1
%37 = add i32 %16, 1
%38 = icmp eq i32 %36, %14
br i1 %38, label %39, label %15
39: ; preds = %35, %9
br i1 %6, label %40, label %42
40: ; preds = %39
%41 = tail call i32 @putchar(i32 93)
br label %42
42: ; preds = %40, %39
ret void
}