#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*/ fatal_error(char *, char *);
int new_pdt(unsigned char **, unsigned char *, int, int, int);
int sscanf(char const *, char *, int *, int *);
int /*<<< orphan*/ update_sec4(unsigned char **, unsigned char *);
int f_set_pdt(int mode, unsigned char **sec, float *data, unsigned int ndata,
              char *inv_out, void **local, const char *arg1) {
  unsigned char new_sec4[500];
  int i, pdt, len, copy_metadata;
  if (mode < 0)
    return 0;
  i = sscanf(arg1, "%d:%d", &pdt, &len);
  if (i == 0)
    fatal_error("set_pdt: X=PDT_number[:PDT_SIZE]", "");
  if (i == 1)
    len = -1;
  copy_metadata = arg1[0] == '+';
  i = new_pdt(sec, new_sec4, pdt, len, copy_metadata);
  if (i == 0)
    update_sec4(sec, new_sec4);
  return i;
}


x86 assembly (clang, -O0):
<f_set_pdt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    117b <f_set_pdt+0x3b>
movl   $0x0,-0x4(%rbp)
jmp    123d <f_set_pdt+0xfd>
mov    0x10(%rbp),%rdi
lea    0xe7a(%rip),%rsi
lea    -0x238(%rbp),%rdx
lea    -0x23c(%rbp),%rcx
call   1040 <sscanf@plt>
mov    %eax,-0x234(%rbp)
cmpl   $0x0,-0x234(%rbp)
jne    11bf <f_set_pdt+0x7f>
lea    0xe53(%rip),%rdi
lea    0xe6c(%rip),%rsi
call   1030 <fatal_error@plt>
cmpl   $0x1,-0x234(%rbp)
jne    11d6 <f_set_pdt+0x96>
movl   $0xffffffff,-0x23c(%rbp)
ff ff ff
mov    0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x240(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x230(%rbp),%rsi
mov    -0x238(%rbp),%edx
mov    -0x23c(%rbp),%ecx
mov    -0x240(%rbp),%r8d
call   1050 <new_pdt@plt>
mov    %eax,-0x234(%rbp)
cmpl   $0x0,-0x234(%rbp)
jne    1234 <f_set_pdt+0xf4>
mov    -0x10(%rbp),%rdi
lea    -0x230(%rbp),%rsi
call   1060 <update_sec4@plt>
mov    -0x234(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_set_pdt>:
push   %r14
push   %rbx
sub    $0x208,%rsp
xor    %eax,%eax
test   %edi,%edi
js     11cd <f_set_pdt+0x8d>
mov    %rsi,%rbx
mov    0x220(%rsp),%r14
lea    0xe9e(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %r14,%rdi
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     1192 <f_set_pdt+0x52>
test   %eax,%eax
jne    119a <f_set_pdt+0x5a>
lea    0xe82(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1030 <fatal_error@plt>
jmp    119a <f_set_pdt+0x5a>
movl   $0xffffffff,0x8(%rsp)
ff
xor    %r8d,%r8d
cmpb   $0x2b,(%r14)
sete   %r8b
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <new_pdt@plt>
test   %eax,%eax
jne    11cd <f_set_pdt+0x8d>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <update_sec4@plt>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d:%d\00"
@.str.1 = [33 x i8] c"set_pdt: X=PDT_number[:PDT_SIZE]\00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @f_set_pdt(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i8** %5, i8* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8**
%11 = alloca float*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8**
%15 = alloca i8*
%16 = alloca [500 x i8]
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store i32 %0, i32* %9
store i8** %1, i8*** %10
store float* %2, float** %11
store i32 %3, i32* %12
store i8* %4, i8** %13
store i8** %5, i8*** %14
store i8* %6, i8** %15
%21 = load i32, i32* %9
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %7
store i32 0, i32* %8
br label %56
24: ; preds = %7
%25 = load i8*, i8** %15
%26 = call i32 @sscanf(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %18, i32* %19)
store i32 %26, i32* %17
%27 = load i32, i32* %17
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 @fatal_error(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %29, %24
%32 = load i32, i32* %17
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %35
34: ; preds = %31
store i32 -1, i32* %19
br label %35
35: ; preds = %34, %31
%36 = load i8*, i8** %15
%37 = getelementptr inbounds i8, i8* %36, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 43
%41 = zext i1 %40 to i32
store i32 %41, i32* %20
%42 = load i8**, i8*** %10
%43 = getelementptr inbounds [500 x i8], [500 x i8]* %16, i64 0, i64 0
%44 = load i32, i32* %18
%45 = load i32, i32* %19
%46 = load i32, i32* %20
%47 = call i32 @new_pdt(i8** %42, i8* %43, i32 %44, i32 %45, i32 %46)
store i32 %47, i32* %17
%48 = load i32, i32* %17
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %35
%51 = load i8**, i8*** %10
%52 = getelementptr inbounds [500 x i8], [500 x i8]* %16, i64 0, i64 0
%53 = call i32 @update_sec4(i8** %51, i8* %52)
br label %54
54: ; preds = %50, %35
%55 = load i32, i32* %17
store i32 %55, i32* %8
br label %56
56: ; preds = %54, %23
%57 = load i32, i32* %8
ret i32 %57
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d:%d\00"
@.str.1 = [33 x i8] c"set_pdt: X=PDT_number[:PDT_SIZE]\00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @f_set_pdt(i32 %0, i8** %1, float* nocapture readnone %2, i32 %3, i8* nocapture readnone %4, i8** nocapture readnone %5, i8* nocapture %6) {
%8 = alloca [500 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%12 = bitcast i32* %9 to i8*
%13 = bitcast i32* %10 to i8*
%14 = icmp slt i32 %0, 0
br i1 %14, label %30, label %15
15: ; preds = %7
%16 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %9, i32* %10)
switch i32 %16, label %20 [
i32 0, label %17
i32 1, label %19
]
17: ; preds = %15
%18 = call i32 @fatal_error(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %20
19: ; preds = %15
store i32 -1, i32* %10
br label %20
20: ; preds = %17, %15, %19
%21 = load i8, i8* %6
%22 = icmp eq i8 %21, 43
%23 = zext i1 %22 to i32
%24 = load i32, i32* %9
%25 = load i32, i32* %10
%26 = call i32 @new_pdt(i8** %1, i8* %11, i32 %24, i32 %25, i32 %23)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %20
%29 = call i32 @update_sec4(i8** %1, i8* %11)
br label %30
30: ; preds = %20, %28, %7
%31 = phi i32 [ 0, %7 ], [ 0, %28 ], [ %26, %20 ]
ret i32 %31
}