#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 unsigned int uint32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ dump_int16_t(int /*<<< orphan*/ *, int, int, int);
int /*<<< orphan*/ dump_int32_t(int /*<<< orphan*/ *, int, int, int);
int /*<<< orphan*/ dump_int64_t(int /*<<< orphan*/ *, int, int, int);
int /*<<< orphan*/ dump_int8_t(int /*<<< orphan*/ *, int, int, int);
int /*<<< orphan*/ dump_uint16_t(int /*<<< orphan*/ *, int, int, int);
int /*<<< orphan*/ dump_uint32_t(int /*<<< orphan*/ *, int, int, int);
int /*<<< orphan*/ dump_uint64_t(int /*<<< orphan*/ *, int, int, int);
int /*<<< orphan*/ dump_uint8_t(int /*<<< orphan*/ *, int, int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(unsigned int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *ouvrir(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
void dump_matrix_new(char *fic, int all, int strict, int magma) {
  FILE *fh = ouvrir(fic, "r");
  fprintf(stderr, "proposed format printing\n");
  uint32_t b;
  assert(fread(&(b), sizeof(uint32_t), 1, fh) == 1);
  ;
  if ((b & (1U << 31)) != (1U << 31)) {
    fprintf(stderr, "error : file %s has bad version number \n", fic);
  }
  b = b ^ (1U << 31);
  switch (b & 1) {
  case (0):
    switch (b >> 1) {
    case 0:
      dump_uint8_t(fh, all, strict, magma);
      break;
    case 1:
      dump_uint16_t(fh, all, strict, magma);
      break;
    case 2:
      dump_uint32_t(fh, all, strict, magma);
      break;
    case 3:
      dump_uint64_t(fh, all, strict, magma);
      break;
    default:
      exit(-2);
    }
    break;
  case (1):
    switch (b >> 1) {
    case 0:
      dump_int8_t(fh, all, strict, magma);
      break;
    case 1:
      dump_int16_t(fh, all, strict, magma);
      break;
    case 2:
      dump_int32_t(fh, all, strict, magma);
      break;
    case 3:
      dump_int64_t(fh, all, strict, magma);
      break;
    default:
      exit(-2);
    }
  }
  if (magma)
    printf("// ----------------------------------------\n");
  else if (strict)
    printf("0 0 0\n");
  fclose(fh);
}


x86 assembly (clang, -O0):
<dump_matrix_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe10(%rip),%rsi
call   1070 <ouvrir@plt>
mov    %rax,-0x20(%rbp)
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
lea    0xdf9(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x20(%rbp),%rcx
lea    -0x24(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x24(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x80000000,%eax
je     1285 <dump_matrix_new+0x95>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xdbe(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x21(%rbp),%al
xor    $0x80,%al
mov    %al,-0x21(%rbp)
mov    -0x24(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0x28(%rbp)
je     12b2 <dump_matrix_new+0xc2>
jmp    12a1 <dump_matrix_new+0xb1>
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
je     1345 <dump_matrix_new+0x155>
jmp    13d8 <dump_matrix_new+0x1e8>
mov    -0x24(%rbp),%eax
shr    %eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x3,%eax
ja     1336 <dump_matrix_new+0x146>
mov    -0x30(%rbp),%rax
lea    0xd3f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <dump_uint8_t@plt>
jmp    1340 <dump_matrix_new+0x150>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1090 <dump_uint16_t@plt>
jmp    1340 <dump_matrix_new+0x150>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   10e0 <dump_uint32_t@plt>
jmp    1340 <dump_matrix_new+0x150>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   10d0 <dump_uint64_t@plt>
jmp    1340 <dump_matrix_new+0x150>
mov    $0xfffffffe,%edi
call   1100 <exit@plt>
jmp    13d8 <dump_matrix_new+0x1e8>
mov    -0x24(%rbp),%eax
shr    %eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x3,%eax
ja     13c9 <dump_matrix_new+0x1d9>
mov    -0x38(%rbp),%rax
lea    0xc9c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1110 <dump_int8_t@plt>
jmp    13d3 <dump_matrix_new+0x1e3>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   10f0 <dump_int16_t@plt>
jmp    13d3 <dump_matrix_new+0x1e3>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1060 <dump_int32_t@plt>
jmp    13d3 <dump_matrix_new+0x1e3>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   10c0 <dump_int64_t@plt>
jmp    13d3 <dump_matrix_new+0x1e3>
mov    $0xfffffffe,%edi
call   1100 <exit@plt>
jmp    13d8 <dump_matrix_new+0x1e8>
cmpl   $0x0,-0x14(%rbp)
je     13f3 <dump_matrix_new+0x203>
lea    0xc7c(%rip),%rdi
call   1080 <printf@plt>
jmp    140e <dump_matrix_new+0x21e>
cmpl   $0x0,-0x10(%rbp)
je     1409 <dump_matrix_new+0x219>
lea    0xc8e(%rip),%rdi
call   1080 <printf@plt>
jmp    140e <dump_matrix_new+0x21e>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_matrix_new>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r12d
mov    %edx,(%rsp)
mov    %esi,%r15d
mov    %rdi,%rbp
lea    0xe12(%rip),%rsi
call   1080 <ouvrir@plt>
mov    %rax,%r13
mov    0x2dc3(%rip),%rbx
mov    (%rbx),%edi
lea    0xdfc(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1050 <fread@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   10a0 <assert@plt>
mov    0x4(%rsp),%r14d
test   %r14d,%r14d
js     126f <dump_matrix_new+0x7f>
mov    (%rbx),%edi
lea    0xdd7(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    %r14d,%eax
shr    %eax
xor    $0x40000000,%eax
test   $0x1,%r14b
jne    12bb <dump_matrix_new+0xcb>
cmp    $0x3,%eax
ja     13c1 <dump_matrix_new+0x1d1>
mov    %eax,%eax
lea    0xd7f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %r13,%rdi
mov    %r15d,%esi
mov    (%rsp),%ebx
mov    %ebx,%edx
mov    %r12d,%ecx
call   1040 <dump_uint8_t@plt>
test   %r12d,%r12d
jne    137a <dump_matrix_new+0x18a>
jmp    139b <dump_matrix_new+0x1ab>
cmp    $0x3,%eax
ja     13c1 <dump_matrix_new+0x1d1>
mov    %eax,%eax
lea    0xd33(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %r13,%rdi
mov    %r15d,%esi
mov    (%rsp),%ebx
mov    %ebx,%edx
mov    %r12d,%ecx
call   1110 <dump_int8_t@plt>
test   %r12d,%r12d
jne    137a <dump_matrix_new+0x18a>
jmp    139b <dump_matrix_new+0x1ab>
mov    %r13,%rdi
mov    %r15d,%esi
mov    (%rsp),%ebx
mov    %ebx,%edx
mov    %r12d,%ecx
call   10e0 <dump_uint32_t@plt>
test   %r12d,%r12d
jne    137a <dump_matrix_new+0x18a>
jmp    139b <dump_matrix_new+0x1ab>
mov    %r13,%rdi
mov    %r15d,%esi
mov    (%rsp),%ebx
mov    %ebx,%edx
mov    %r12d,%ecx
call   1070 <dump_int32_t@plt>
test   %r12d,%r12d
jne    137a <dump_matrix_new+0x18a>
jmp    139b <dump_matrix_new+0x1ab>
mov    %r13,%rdi
mov    %r15d,%esi
mov    (%rsp),%ebx
mov    %ebx,%edx
mov    %r12d,%ecx
call   1090 <dump_uint16_t@plt>
test   %r12d,%r12d
jne    137a <dump_matrix_new+0x18a>
jmp    139b <dump_matrix_new+0x1ab>
mov    %r13,%rdi
mov    %r15d,%esi
mov    (%rsp),%ebx
mov    %ebx,%edx
mov    %r12d,%ecx
call   10d0 <dump_uint64_t@plt>
test   %r12d,%r12d
jne    137a <dump_matrix_new+0x18a>
jmp    139b <dump_matrix_new+0x1ab>
mov    %r13,%rdi
mov    %r15d,%esi
mov    (%rsp),%ebx
mov    %ebx,%edx
mov    %r12d,%ecx
call   10f0 <dump_int16_t@plt>
test   %r12d,%r12d
je     139b <dump_matrix_new+0x1ab>
lea    0xcea(%rip),%rdi
jmp    13a6 <dump_matrix_new+0x1b6>
mov    %r13,%rdi
mov    %r15d,%esi
mov    (%rsp),%ebx
mov    %ebx,%edx
mov    %r12d,%ecx
call   10c0 <dump_int64_t@plt>
test   %r12d,%r12d
jne    137a <dump_matrix_new+0x18a>
test   %ebx,%ebx
je     13ab <dump_matrix_new+0x1bb>
lea    0xcbf(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fclose@plt>
mov    $0xfffffffe,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"proposed format printing\0A\00"
@.str.2 = [41 x i8] c"error : file %s has bad version number \0A\00"
@.str.3 = [45 x i8] c"// ----------------------------------------\0A\00"
@.str.4 = [7 x i8] c"0 0 0\0A\00"
define void @dump_matrix_new(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
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i8*, i8** %5
%12 = call i32* @ouvrir(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %9
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32*, i32** %9
%16 = call i32 @fread(i32* %10, i32 4, i32 1, i32* %15)
%17 = icmp eq i32 %16, 1
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load i32, i32* %10
%21 = and i32 %20, -2147483648
%22 = icmp ne i32 %21, -2147483648
br i1 %22, label %23, label %27
23: ; preds = %4
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %5
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %23, %4
%28 = load i32, i32* %10
%29 = xor i32 %28, -2147483648
store i32 %29, i32* %10
%30 = load i32, i32* %10
%31 = and i32 %30, 1
switch i32 %31, label %92 [
i32 0, label %32
i32 1, label %62
]
32: ; preds = %27
%33 = load i32, i32* %10
%34 = lshr i32 %33, 1
switch i32 %34, label %59 [
i32 0, label %35
i32 1, label %41
i32 2, label %47
i32 3, label %53
]
35: ; preds = %32
%36 = load i32*, i32** %9
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = load i32, i32* %8
%40 = call i32 @dump_uint8_t(i32* %36, i32 %37, i32 %38, i32 %39)
br label %61
41: ; preds = %32
%42 = load i32*, i32** %9
%43 = load i32, i32* %6
%44 = load i32, i32* %7
%45 = load i32, i32* %8
%46 = call i32 @dump_uint16_t(i32* %42, i32 %43, i32 %44, i32 %45)
br label %61
47: ; preds = %32
%48 = load i32*, i32** %9
%49 = load i32, i32* %6
%50 = load i32, i32* %7
%51 = load i32, i32* %8
%52 = call i32 @dump_uint32_t(i32* %48, i32 %49, i32 %50, i32 %51)
br label %61
53: ; preds = %32
%54 = load i32*, i32** %9
%55 = load i32, i32* %6
%56 = load i32, i32* %7
%57 = load i32, i32* %8
%58 = call i32 @dump_uint64_t(i32* %54, i32 %55, i32 %56, i32 %57)
br label %61
59: ; preds = %32
%60 = call i32 @exit(i32 -2)
unreachable
61: ; preds = %53, %47, %41, %35
br label %92
62: ; preds = %27
%63 = load i32, i32* %10
%64 = lshr i32 %63, 1
switch i32 %64, label %89 [
i32 0, label %65
i32 1, label %71
i32 2, label %77
i32 3, label %83
]
65: ; preds = %62
%66 = load i32*, i32** %9
%67 = load i32, i32* %6
%68 = load i32, i32* %7
%69 = load i32, i32* %8
%70 = call i32 @dump_int8_t(i32* %66, i32 %67, i32 %68, i32 %69)
br label %91
71: ; preds = %62
%72 = load i32*, i32** %9
%73 = load i32, i32* %6
%74 = load i32, i32* %7
%75 = load i32, i32* %8
%76 = call i32 @dump_int16_t(i32* %72, i32 %73, i32 %74, i32 %75)
br label %91
77: ; preds = %62
%78 = load i32*, i32** %9
%79 = load i32, i32* %6
%80 = load i32, i32* %7
%81 = load i32, i32* %8
%82 = call i32 @dump_int32_t(i32* %78, i32 %79, i32 %80, i32 %81)
br label %91
83: ; preds = %62
%84 = load i32*, i32** %9
%85 = load i32, i32* %6
%86 = load i32, i32* %7
%87 = load i32, i32* %8
%88 = call i32 @dump_int64_t(i32* %84, i32 %85, i32 %86, i32 %87)
br label %91
89: ; preds = %62
%90 = call i32 @exit(i32 -2)
unreachable
91: ; preds = %83, %77, %71, %65
br label %92
92: ; preds = %91, %27, %61
%93 = load i32, i32* %8
%94 = icmp ne i32 %93, 0
br i1 %94, label %95, label %97
95: ; preds = %92
%96 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
br label %103
97: ; preds = %92
%98 = load i32, i32* %7
%99 = icmp ne i32 %98, 0
br i1 %99, label %100, label %102
100: ; preds = %97
%101 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %102
102: ; preds = %100, %97
br label %103
103: ; preds = %102, %95
%104 = load i32*, i32** %9
%105 = call i32 @fclose(i32* %104)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"proposed format printing\0A\00"
@.str.2 = [41 x i8] c"error : file %s has bad version number \0A\00"
@str = [6 x i8] c"0 0 0\00"
@str.5 = [44 x i8] c"// ----------------------------------------\00"
define void @dump_matrix_new(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = tail call i32* @ouvrir(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%9 = bitcast i32* %5 to i8*
%10 = call i32 @fread(i32* %5, i32 4, i32 1, i32* %6)
%11 = icmp eq i32 %10, 1
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %4
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %19
19: ; preds = %16, %4
%20 = and i32 %14, 1
%21 = icmp eq i32 %20, 0
%22 = lshr i32 %14, 1
%23 = xor i32 %22, 1073741824
br i1 %21, label %24, label %35
24: ; preds = %19
switch i32 %23, label %33 [
i32 0, label %25
i32 1, label %27
i32 2, label %29
i32 3, label %31
]
25: ; preds = %24
%26 = tail call i32 @dump_uint8_t(i32* %6, i32 %1, i32 %2, i32 %3)
br label %46
27: ; preds = %24
%28 = tail call i32 @dump_uint16_t(i32* %6, i32 %1, i32 %2, i32 %3)
br label %46
29: ; preds = %24
%30 = tail call i32 @dump_uint32_t(i32* %6, i32 %1, i32 %2, i32 %3)
br label %46
31: ; preds = %24
%32 = tail call i32 @dump_uint64_t(i32* %6, i32 %1, i32 %2, i32 %3)
br label %46
33: ; preds = %24
%34 = tail call i32 @exit(i32 -2)
unreachable
35: ; preds = %19
switch i32 %23, label %44 [
i32 0, label %36
i32 1, label %38
i32 2, label %40
i32 3, label %42
]
36: ; preds = %35
%37 = tail call i32 @dump_int8_t(i32* %6, i32 %1, i32 %2, i32 %3)
br label %46
38: ; preds = %35
%39 = tail call i32 @dump_int16_t(i32* %6, i32 %1, i32 %2, i32 %3)
br label %46
40: ; preds = %35
%41 = tail call i32 @dump_int32_t(i32* %6, i32 %1, i32 %2, i32 %3)
br label %46
42: ; preds = %35
%43 = tail call i32 @dump_int64_t(i32* %6, i32 %1, i32 %2, i32 %3)
br label %46
44: ; preds = %35
%45 = tail call i32 @exit(i32 -2)
unreachable
46: ; preds = %36, %38, %40, %42, %25, %27, %29, %31
%47 = icmp eq i32 %3, 0
br i1 %47, label %48, label %50
48: ; preds = %46
%49 = icmp eq i32 %2, 0
br i1 %49, label %53, label %50
50: ; preds = %48, %46
%51 = phi i8* [ getelementptr inbounds ([44 x i8], [44 x i8]* @str.5, i64 0, i64 0), %46 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0), %48 ]
%52 = tail call i32 @puts(i8* dereferenceable(1) %51)
br label %53
53: ; preds = %50, %48
%54 = tail call i32 @fclose(i32* %6)
ret void
}