#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 atoi(char const *);
int /*<<< orphan*/ fatal_error(char *, char const *);
int sscanf(char const *, char *, unsigned int *, int *);
int uint4(unsigned char *);
int f_set_byte(int mode, unsigned char **sec, float *data, unsigned int ndata,
               char *inv_out, void **local, const char *arg1, const char *arg2,
               const char *arg3) {
  int i, j, k, m, seclen;
  unsigned int val;
  if (mode < 0)
    return 0;
  i = atoi(arg1);
  j = atoi(arg2);
  if (i < 0 || i > 8)
    fatal_error("set_byte: bad section number %s", arg1);
  if (j <= 0)
    fatal_error("set_byte: octet number must >= 1", "");
  if (i == 0)
    seclen = 16;
  else if (i == 8)
    seclen = 4;
  else
    seclen = uint4(sec[i]);
  k = sscanf(arg3, "%u%n", &val, &m);
  while (k == 1) {
    if (j > seclen)
      fatal_error("set_byte out of bounds section %s", arg1);
    sec[i][j++ - 1] = val;
    arg3 += m;
    k = sscanf(arg3, ":%u%n", &val, &m);
  }
  return 0;
}


x86 assembly (clang, -O0):
<f_set_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
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    1180 <f_set_byte+0x40>
movl   $0x0,-0x4(%rbp)
jmp    12bc <f_set_byte+0x17c>
mov    0x10(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x34(%rbp)
mov    0x18(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x34(%rbp)
jl     11ac <f_set_byte+0x6c>
cmpl   $0x8,-0x34(%rbp)
jle    11bc <f_set_byte+0x7c>
mov    0x10(%rbp),%rsi
lea    0xe49(%rip),%rdi
call   1040 <fatal_error@plt>
cmpl   $0x0,-0x38(%rbp)
jg     11d9 <f_set_byte+0x99>
lea    0xe53(%rip),%rdi
lea    0xe6c(%rip),%rsi
call   1040 <fatal_error@plt>
cmpl   $0x0,-0x34(%rbp)
jne    11ef <f_set_byte+0xaf>
movl   $0x10,-0x44(%rbp)
jmp    121e <f_set_byte+0xde>
cmpl   $0x8,-0x34(%rbp)
jne    1205 <f_set_byte+0xc5>
movl   $0x4,-0x44(%rbp)
jmp    1219 <f_set_byte+0xd9>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <uint4@plt>
mov    %eax,-0x44(%rbp)
jmp    121e <f_set_byte+0xde>
mov    0x20(%rbp),%rdi
lea    0xe3b(%rip),%rsi
lea    -0x48(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   1050 <sscanf@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x1,-0x3c(%rbp)
jne    12b5 <f_set_byte+0x175>
mov    -0x38(%rbp),%eax
cmp    -0x44(%rbp),%eax
jle    125f <f_set_byte+0x11f>
mov    0x10(%rbp),%rsi
lea    0xde7(%rip),%rdi
call   1040 <fatal_error@plt>
mov    -0x48(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x38(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x38(%rbp)
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x40(%rbp),%ecx
mov    0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,0x20(%rbp)
mov    0x20(%rbp),%rdi
lea    0xdc3(%rip),%rsi
lea    -0x48(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   1050 <sscanf@plt>
mov    %eax,-0x3c(%rbp)
jmp    1239 <f_set_byte+0xf9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_set_byte>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
test   %edi,%edi
js     1261 <f_set_byte+0x121>
mov    0x58(%rsp),%rbx
mov    0x50(%rsp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %eax,%r14d
cmp    $0x9,%ebp
jb     118d <f_set_byte+0x4d>
lea    0xe7d(%rip),%rdi
mov    0x50(%rsp),%rsi
call   1040 <fatal_error@plt>
test   %r14d,%r14d
jg     11a5 <f_set_byte+0x65>
lea    0xe87(%rip),%rdi
lea    0xea0(%rip),%rsi
call   1040 <fatal_error@plt>
mov    0x60(%rsp),%rbx
test   %ebp,%ebp
je     11bb <f_set_byte+0x7b>
cmp    $0x8,%ebp
jne    11c3 <f_set_byte+0x83>
mov    $0x4,%r12d
jmp    11d7 <f_set_byte+0x97>
mov    $0x10,%r12d
jmp    11d7 <f_set_byte+0x97>
movslq %ebp,%rax
mov    0x10(%rsp),%rcx
mov    (%rcx,%rax,8),%rdi
call   1030 <uint4@plt>
movslq %eax,%r12
lea    0xe86(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rbx,%rdi
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    1261 <f_set_byte+0x121>
movslq %ebp,%r15
movslq %r14d,%r13
lea    0x8(%rsp),%rbp
lea    0xc(%rsp),%r14
jmp    1249 <f_set_byte+0x109>
nopw   0x0(%rax,%rax,1)
movzbl 0x8(%rsp),%eax
mov    0x10(%rsp),%rcx
mov    (%rcx,%r15,8),%rcx
mov    %al,-0x1(%rcx,%r13,1)
add    $0x1,%r13
movslq 0xc(%rsp),%rax
add    %rax,%rbx
mov    %rbx,%rdi
lea    0xe2a(%rip),%rsi
mov    %rbp,%rdx
mov    %r14,%rcx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    1261 <f_set_byte+0x121>
cmp    %r12,%r13
jle    1210 <f_set_byte+0xd0>
lea    0xdec(%rip),%rdi
mov    0x50(%rsp),%rsi
call   1040 <fatal_error@plt>
jmp    1210 <f_set_byte+0xd0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"set_byte: bad section number %s\00"
@.str.1 = [33 x i8] c"set_byte: octet number must >= 1\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [5 x i8] c"%u%n\00"
@.str.4 = [34 x i8] c"set_byte out of bounds section %s\00"
@.str.5 = [6 x i8] c":%u%n\00"
define i32 @f_set_byte(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i8** %5, i8* %6, i8* %7, i8* %8) {
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8**
%13 = alloca float*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8**
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
store i32 %0, i32* %11
store i8** %1, i8*** %12
store float* %2, float** %13
store i32 %3, i32* %14
store i8* %4, i8** %15
store i8** %5, i8*** %16
store i8* %6, i8** %17
store i8* %7, i8** %18
store i8* %8, i8** %19
%26 = load i32, i32* %11
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %9
store i32 0, i32* %10
br label %96
29: ; preds = %9
%30 = load i8*, i8** %17
%31 = call i32 @atoi(i8* %30)
store i32 %31, i32* %20
%32 = load i8*, i8** %18
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %21
%34 = load i32, i32* %20
%35 = icmp slt i32 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %29
%37 = load i32, i32* %20
%38 = icmp sgt i32 %37, 8
br i1 %38, label %39, label %42
39: ; preds = %36, %29
%40 = load i8*, i8** %17
%41 = call i32 @fatal_error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %40)
br label %42
42: ; preds = %39, %36
%43 = load i32, i32* %21
%44 = icmp sle i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = 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 %47
47: ; preds = %45, %42
%48 = load i32, i32* %20
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %47
store i32 16, i32* %24
br label %63
51: ; preds = %47
%52 = load i32, i32* %20
%53 = icmp eq i32 %52, 8
br i1 %53, label %54, label %55
54: ; preds = %51
store i32 4, i32* %24
br label %62
55: ; preds = %51
%56 = load i8**, i8*** %12
%57 = load i32, i32* %20
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = call i32 @uint4(i8* %60)
store i32 %61, i32* %24
br label %62
62: ; preds = %55, %54
br label %63
63: ; preds = %62, %50
%64 = load i8*, i8** %19
%65 = call i32 @sscanf(i8* %64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* %25, i32* %23)
store i32 %65, i32* %22
br label %66
66: ; preds = %76, %63
%67 = load i32, i32* %22
%68 = icmp eq i32 %67, 1
br i1 %68, label %69, label %95
69: ; preds = %66
%70 = load i32, i32* %21
%71 = load i32, i32* %24
%72 = icmp sgt i32 %70, %71
br i1 %72, label %73, label %76
73: ; preds = %69
%74 = load i8*, i8** %17
%75 = call i32 @fatal_error(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %74)
br label %76
76: ; preds = %73, %69
%77 = load i32, i32* %25
%78 = trunc i32 %77 to i8
%79 = load i8**, i8*** %12
%80 = load i32, i32* %20
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8*, i8** %79, i64 %81
%83 = load i8*, i8** %82
%84 = load i32, i32* %21
%85 = add nsw i32 %84, 1
store i32 %85, i32* %21
%86 = sub nsw i32 %84, 1
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8, i8* %83, i64 %87
store i8 %78, i8* %88
%89 = load i32, i32* %23
%90 = load i8*, i8** %19
%91 = sext i32 %89 to i64
%92 = getelementptr inbounds i8, i8* %90, i64 %91
store i8* %92, i8** %19
%93 = load i8*, i8** %19
%94 = call i32 @sscanf(i8* %93, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %25, i32* %23)
store i32 %94, i32* %22
br label %66
95: ; preds = %66
store i32 0, i32* %10
br label %96
96: ; preds = %95, %28
%97 = load i32, i32* %10
ret i32 %97
}

LLVM IR (-O2):
@.str = [32 x i8] c"set_byte: bad section number %s\00"
@.str.1 = [33 x i8] c"set_byte: octet number must >= 1\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [5 x i8] c"%u%n\00"
@.str.4 = [34 x i8] c"set_byte out of bounds section %s\00"
@.str.5 = [6 x i8] c":%u%n\00"
define i32 @f_set_byte(i32 %0, i8** nocapture %1, float* nocapture readnone %2, i32 %3, i8* nocapture readnone %4, i8** nocapture readnone %5, i8* %6, i8* nocapture %7, i8* nocapture %8) {
%10 = alloca i32
%11 = alloca i32
%12 = bitcast i32* %10 to i8*
%13 = bitcast i32* %11 to i8*
%14 = icmp slt i32 %0, 0
br i1 %14, label %59, label %15
15: ; preds = %9
%16 = tail call i32 @atoi(i8* %6)
%17 = tail call i32 @atoi(i8* %7)
%18 = icmp ugt i32 %16, 8
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = tail call i32 @fatal_error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %21
21: ; preds = %15, %19
%22 = icmp slt i32 %17, 1
br i1 %22, label %23, label %25
23: ; preds = %21
%24 = tail 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 %25
25: ; preds = %23, %21
switch i32 %16, label %27 [
i32 0, label %33
i32 8, label %26
]
26: ; preds = %25
br label %33
27: ; preds = %25
%28 = sext i32 %16 to i64
%29 = getelementptr inbounds i8*, i8** %1, i64 %28
%30 = load i8*, i8** %29
%31 = tail call i32 @uint4(i8* %30)
%32 = sext i32 %31 to i64
br label %33
33: ; preds = %25, %26, %27
%34 = phi i64 [ 4, %26 ], [ %32, %27 ], [ 16, %25 ]
%35 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* %11, i32* %10)
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %59
37: ; preds = %33
%38 = sext i32 %16 to i64
%39 = getelementptr inbounds i8*, i8** %1, i64 %38
%40 = sext i32 %17 to i64
br label %41
41: ; preds = %37, %47
%42 = phi i64 [ %40, %37 ], [ %51, %47 ]
%43 = phi i8* [ %8, %37 ], [ %56, %47 ]
%44 = icmp sgt i64 %42, %34
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 @fatal_error(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %6)
br label %47
47: ; preds = %45, %41
%48 = load i32, i32* %11
%49 = trunc i32 %48 to i8
%50 = load i8*, i8** %39
%51 = add i64 %42, 1
%52 = add nsw i64 %42, -1
%53 = getelementptr inbounds i8, i8* %50, i64 %52
store i8 %49, i8* %53
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %43, i64 %55
%57 = call i32 @sscanf(i8* %56, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %11, i32* %10)
%58 = icmp eq i32 %57, 1
br i1 %58, label %41, label %59
59: ; preds = %47, %33, %9
ret i32 0
}