#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 code_table_3_1(unsigned char **);
int /*<<< orphan*/ fatal_error(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int, unsigned char);
int uint4(unsigned char *);
int f_Sec3(int mode, unsigned char **sec, float *data, unsigned int ndata,
           char *inv_out, void **local) {
  unsigned char *p;
  if (mode >= 0) {
    p = sec[3];
    if (p[4] != 3) {
      fatal_error("Sec3 was expected and not found", "");
    }
    sprintf(inv_out,
            "Sec3 len=%u src gdef=%d npts=%d Grid Def Template=3.%d opt arg=%u",
            (sec[3] ? uint4(sec[3] + 0) : 0), ((int)(sec[3][5])),
            uint4(sec[3] + 6), code_table_3_1(sec), p[10]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<f_Sec3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     1228 <f_Sec3+0xe8>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movzbl 0x4(%rax),%eax
cmp    $0x3,%eax
je     1198 <f_Sec3+0x58>
lea    0xe74(%rip),%rdi
lea    0xe8c(%rip),%rsi
call   1050 <fatal_error@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x18(%rax)
je     11c4 <f_Sec3+0x84>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <uint4@plt>
mov    %eax,-0x44(%rbp)
jmp    11ce <f_Sec3+0x8e>
xor    %eax,%eax
mov    %eax,-0x44(%rbp)
jmp    11ce <f_Sec3+0x8e>
mov    -0x44(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movzbl 0x5(%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
add    $0x6,%rdi
call   1040 <uint4@plt>
mov    %eax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <code_table_3_1@plt>
mov    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%edx
mov    -0x4c(%rbp),%ecx
mov    -0x48(%rbp),%r8d
mov    %eax,%r9d
mov    -0x38(%rbp),%rax
lea    0xe04(%rip),%rsi
movzbl 0xa(%rax),%eax
mov    %eax,(%rsp)
call   1060 <sprintf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_Sec3>:
test   %edi,%edi
js     11d2 <f_Sec3+0x92>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rsi,%rbx
mov    0x18(%rsi),%rbp
cmpb   $0x3,0x4(%rbp)
mov    %rbp,%rdi
je     117d <f_Sec3+0x3d>
lea    0xe93(%rip),%rdi
lea    0xeab(%rip),%rsi
call   1050 <fatal_error@plt>
mov    0x18(%rbx),%rdi
call   1040 <uint4@plt>
mov    %eax,%r15d
mov    0x18(%rbx),%rdi
movzbl 0x5(%rdi),%r12d
add    $0x6,%rdi
call   1040 <uint4@plt>
mov    %eax,%r13d
mov    %rbx,%rdi
call   1030 <code_table_3_1@plt>
movzbl 0xa(%rbp),%ecx
mov    %ecx,(%rsp)
lea    0xe70(%rip),%rsi
mov    %r14,%rdi
mov    %r15d,%edx
mov    %r12d,%ecx
mov    %r13d,%r8d
mov    %eax,%r9d
call   1060 <sprintf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Sec3 was expected and not found\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [66 x i8] c"Sec3 len=%u src gdef=%d npts=%d Grid Def Template=3.%d opt arg=%u\00"
define i32 @f_Sec3(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i8** %5) {
%7 = alloca i32
%8 = alloca i8**
%9 = alloca float*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8**
%13 = alloca i8*
store i32 %0, i32* %7
store i8** %1, i8*** %8
store float* %2, float** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i8** %5, i8*** %12
%14 = load i32, i32* %7
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %59
16: ; preds = %6
%17 = load i8**, i8*** %8
%18 = getelementptr inbounds i8*, i8** %17, i64 3
%19 = load i8*, i8** %18
store i8* %19, i8** %13
%20 = load i8*, i8** %13
%21 = getelementptr inbounds i8, i8* %20, i64 4
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = icmp ne i32 %23, 3
br i1 %24, label %25, label %27
25: ; preds = %16
%26 = call i32 @fatal_error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %25, %16
%28 = load i8*, i8** %11
%29 = load i8**, i8*** %8
%30 = getelementptr inbounds i8*, i8** %29, i64 3
%31 = load i8*, i8** %30
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %39
33: ; preds = %27
%34 = load i8**, i8*** %8
%35 = getelementptr inbounds i8*, i8** %34, i64 3
%36 = load i8*, i8** %35
%37 = getelementptr inbounds i8, i8* %36, i64 0
%38 = call i32 @uint4(i8* %37)
br label %40
39: ; preds = %27
br label %40
40: ; preds = %39, %33
%41 = phi i32 [ %38, %33 ], [ 0, %39 ]
%42 = load i8**, i8*** %8
%43 = getelementptr inbounds i8*, i8** %42, i64 3
%44 = load i8*, i8** %43
%45 = getelementptr inbounds i8, i8* %44, i64 5
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = load i8**, i8*** %8
%49 = getelementptr inbounds i8*, i8** %48, i64 3
%50 = load i8*, i8** %49
%51 = getelementptr inbounds i8, i8* %50, i64 6
%52 = call i32 @uint4(i8* %51)
%53 = load i8**, i8*** %8
%54 = call i32 @code_table_3_1(i8** %53)
%55 = load i8*, i8** %13
%56 = getelementptr inbounds i8, i8* %55, i64 10
%57 = load i8, i8* %56
%58 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.2, i64 0, i64 0), i32 %41, i32 %47, i32 %52, i32 %54, i8 zeroext %57)
br label %59
59: ; preds = %40, %6
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"Sec3 was expected and not found\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [66 x i8] c"Sec3 len=%u src gdef=%d npts=%d Grid Def Template=3.%d opt arg=%u\00"
define i32 @f_Sec3(i32 %0, i8** %1, float* nocapture readnone %2, i32 %3, i8* nocapture writeonly %4, i8** nocapture readnone %5) {
%7 = icmp sgt i32 %0, -1
br i1 %7, label %8, label %30
8: ; preds = %6
%9 = getelementptr inbounds i8*, i8** %1, i64 3
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8, i8* %10, i64 4
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 3
br i1 %13, label %17, label %14
14: ; preds = %8
%15 = tail call i32 @fatal_error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%16 = load i8*, i8** %9
br label %17
17: ; preds = %14, %8
%18 = phi i8* [ %16, %14 ], [ %10, %8 ]
%19 = tail call i32 @uint4(i8* %18)
%20 = load i8*, i8** %9
%21 = getelementptr inbounds i8, i8* %20, i64 5
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = getelementptr inbounds i8, i8* %20, i64 6
%25 = tail call i32 @uint4(i8* %24)
%26 = tail call i32 @code_table_3_1(i8** %1)
%27 = getelementptr inbounds i8, i8* %10, i64 10
%28 = load i8, i8* %27
%29 = tail call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %23, i32 %25, i32 %26, i8 zeroext %28)
br label %30
30: ; preds = %17, %6
ret i32 0
}