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

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ stderr;
char *strtok(char *, char *);
scalar_t__ strtol(char *, char **, int);
char tolower(char);
int read_param_f(FILE *fp, char *par, char *partyp, int *size, char *fmt) {
  char buf[256], *ch, *stat;
  while (1) {
    if (!fgets(buf, 256, fp)) {
      return -1;
    }
    ch = strtok(buf, " ");
    if (ch && ch[0] == '!')
      continue;
    if (ch && ch[0] == '\n')
      continue;
    break;
  }
  memcpy(par, ch, 26);
  ch = par;
  while (*ch) {
    *ch = tolower(*ch);
    ch++;
  }
  ch = strtok(NULL, " ");
  if (!ch)
    return 1;
  *partyp = *ch;
  ch = strtok(NULL, " ");
  if (!ch)
    return 2;
  *size = (int)strtol(ch, &stat, 10);
  if (*stat) {
    fprintf(stderr, "non-digits in datablock size\n");
    return 3;
  }
  ch = strtok(NULL, " \012");
  if (!fmt)
    return 4;
  memcpy(fmt, ch, 64);
  return 0;
}


x86 assembly (clang, -O0):
<read_param_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
call   1030 <fgets@plt>
cmp    $0x0,%eax
jne    11a9 <read_param_f+0x49>
movl   $0xffffffff,-0x4(%rbp)
jmp    1381 <read_param_f+0x221>
lea    -0x130(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x138(%rbp)
cmpq   $0x0,-0x138(%rbp)
je     11e9 <read_param_f+0x89>
mov    -0x138(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x21,%eax
jne    11e9 <read_param_f+0x89>
jmp    117f <read_param_f+0x1f>
cmpq   $0x0,-0x138(%rbp)
je     120f <read_param_f+0xaf>
mov    -0x138(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    120f <read_param_f+0xaf>
jmp    117f <read_param_f+0x1f>
jmp    1214 <read_param_f+0xb4>
mov    -0x18(%rbp),%rdi
mov    -0x138(%rbp),%rsi
mov    $0x1a,%edx
call   1060 <memcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x138(%rbp),%rax
cmpb   $0x0,(%rax)
je     1275 <read_param_f+0x115>
mov    -0x138(%rbp),%rax
movsbl (%rax),%edi
call   1070 <tolower@plt>
mov    %al,%cl
mov    -0x138(%rbp),%rax
mov    %cl,(%rax)
mov    -0x138(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x138(%rbp)
jmp    1234 <read_param_f+0xd4>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd80(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x138(%rbp)
cmpq   $0x0,-0x138(%rbp)
jne    12a6 <read_param_f+0x146>
movl   $0x1,-0x4(%rbp)
jmp    1381 <read_param_f+0x221>
mov    -0x138(%rbp),%rax
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd40(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x138(%rbp)
cmpq   $0x0,-0x138(%rbp)
jne    12e6 <read_param_f+0x186>
movl   $0x2,-0x4(%rbp)
jmp    1381 <read_param_f+0x221>
mov    -0x138(%rbp),%rdi
lea    -0x140(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x140(%rbp),%rax
cmpb   $0x0,(%rax)
je     1337 <read_param_f+0x1d7>
mov    0x2cc3(%rip),%rax
mov    (%rax),%edi
lea    0xcdc(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1381 <read_param_f+0x221>
xor    %eax,%eax
mov    %eax,%edi
lea    0xcde(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x138(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1365 <read_param_f+0x205>
movl   $0x4,-0x4(%rbp)
jmp    1381 <read_param_f+0x221>
mov    -0x30(%rbp),%rdi
mov    -0x138(%rbp),%rsi
mov    $0x40,%edx
call   1060 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_param_f>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0x20(%rsp),%rdi
mov    $0x100,%esi
mov    %rbp,%rdx
call   1030 <fgets@plt>
mov    $0xffffffff,%r13d
test   %eax,%eax
je     12d6 <read_param_f+0x176>
mov    %r15,0x8(%rsp)
mov    %r14,0x10(%rsp)
lea    0xe4f(%rip),%r14
lea    0x20(%rsp),%r15
jmp    11d8 <read_param_f+0x78>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x100,%esi
mov    %rbp,%rdx
call   1030 <fgets@plt>
test   %eax,%eax
je     12d6 <read_param_f+0x176>
mov    %r15,%rdi
mov    %r14,%rsi
call   1080 <strtok@plt>
test   %rax,%rax
je     11f5 <read_param_f+0x95>
movzbl (%rax),%ecx
cmp    $0x21,%cl
je     11c0 <read_param_f+0x60>
cmp    $0xa,%cl
je     11c0 <read_param_f+0x60>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x1a,%edx
call   1060 <memcpy@plt>
mov    (%rbx),%al
test   %al,%al
je     1226 <read_param_f+0xc6>
add    $0x1,%rbx
nop
movsbl %al,%edi
call   1070 <tolower@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1210 <read_param_f+0xb0>
lea    0xdd3(%rip),%rsi
xor    %edi,%edi
call   1080 <strtok@plt>
test   %rax,%rax
mov    0x10(%rsp),%rbx
mov    0x8(%rsp),%rbp
je     1298 <read_param_f+0x138>
mov    (%rax),%al
mov    %al,(%r12)
lea    0xdb0(%rip),%rsi
xor    %edi,%edi
call   1080 <strtok@plt>
test   %rax,%rax
je     12a0 <read_param_f+0x140>
lea    0x18(%rsp),%rsi
mov    %rax,%rdi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,0x0(%rbp)
mov    0x18(%rsp),%rax
cmpb   $0x0,(%rax)
je     12a8 <read_param_f+0x148>
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
lea    0xd77(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x3,%r13d
jmp    12d6 <read_param_f+0x176>
mov    $0x1,%r13d
jmp    12d6 <read_param_f+0x176>
mov    $0x2,%r13d
jmp    12d6 <read_param_f+0x176>
lea    0xd71(%rip),%rsi
xor    %r13d,%r13d
xor    %edi,%edi
call   1080 <strtok@plt>
test   %rbx,%rbx
je     12d0 <read_param_f+0x170>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x40,%edx
call   1060 <memcpy@plt>
jmp    12d6 <read_param_f+0x176>
mov    $0x4,%r13d
mov    %r13d,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"non-digits in datablock size\0A\00"
@.str.2 = [3 x i8] c" \0A\00"
define i32 @read_param_f(i32* %0, i8* %1, i8* %2, i32* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca [256 x i8]
%13 = alloca i8*
%14 = alloca i8*
store i32* %0, i32** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i32* %3, i32** %10
store i8* %4, i8** %11
br label %15
15: ; preds = %5, %32, %42
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%17 = load i32*, i32** %7
%18 = call i32 @fgets(i8* %16, i32 256, i32* %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %15
store i32 -1, i32* %6
br label %93
21: ; preds = %15
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%23 = call i8* @strtok(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %23, i8** %13
%24 = load i8*, i8** %13
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %33
26: ; preds = %21
%27 = load i8*, i8** %13
%28 = getelementptr inbounds i8, i8* %27, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 33
br i1 %31, label %32, label %33
32: ; preds = %26
br label %15
33: ; preds = %26, %21
%34 = load i8*, i8** %13
%35 = icmp ne i8* %34, null
br i1 %35, label %36, label %43
36: ; preds = %33
%37 = load i8*, i8** %13
%38 = getelementptr inbounds i8, i8* %37, i64 0
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 10
br i1 %41, label %42, label %43
42: ; preds = %36
br label %15
43: ; preds = %36, %33
br label %44
44: ; preds = %43
%45 = load i8*, i8** %8
%46 = load i8*, i8** %13
%47 = call i32 @memcpy(i8* %45, i8* %46, i32 26)
%48 = load i8*, i8** %8
store i8* %48, i8** %13
br label %49
49: ; preds = %53, %44
%50 = load i8*, i8** %13
%51 = load i8, i8* %50
%52 = icmp ne i8 %51, 0
br i1 %52, label %53, label %60
53: ; preds = %49
%54 = load i8*, i8** %13
%55 = load i8, i8* %54
%56 = call signext i8 @tolower(i8 signext %55)
%57 = load i8*, i8** %13
store i8 %56, i8* %57
%58 = load i8*, i8** %13
%59 = getelementptr inbounds i8, i8* %58, i32 1
store i8* %59, i8** %13
br label %49
60: ; preds = %49
%61 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %61, i8** %13
%62 = load i8*, i8** %13
%63 = icmp ne i8* %62, null
br i1 %63, label %65, label %64
64: ; preds = %60
store i32 1, i32* %6
br label %93
65: ; preds = %60
%66 = load i8*, i8** %13
%67 = load i8, i8* %66
%68 = load i8*, i8** %9
store i8 %67, i8* %68
%69 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %69, i8** %13
%70 = load i8*, i8** %13
%71 = icmp ne i8* %70, null
br i1 %71, label %73, label %72
72: ; preds = %65
store i32 2, i32* %6
br label %93
73: ; preds = %65
%74 = load i8*, i8** %13
%75 = call i64 @strtol(i8* %74, i8** %14, i32 10)
%76 = trunc i64 %75 to i32
%77 = load i32*, i32** %10
store i32 %76, i32* %77
%78 = load i8*, i8** %14
%79 = load i8, i8* %78
%80 = icmp ne i8 %79, 0
br i1 %80, label %81, label %84
81: ; preds = %73
%82 = load i32, i32* @stderr
%83 = call i32 @fprintf(i32 %82, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
store i32 3, i32* %6
br label %93
84: ; preds = %73
%85 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %85, i8** %13
%86 = load i8*, i8** %11
%87 = icmp ne i8* %86, null
br i1 %87, label %89, label %88
88: ; preds = %84
store i32 4, i32* %6
br label %93
89: ; preds = %84
%90 = load i8*, i8** %11
%91 = load i8*, i8** %13
%92 = call i32 @memcpy(i8* %90, i8* %91, i32 64)
store i32 0, i32* %6
br label %93
93: ; preds = %89, %88, %81, %72, %64, %20
%94 = load i32, i32* %6
ret i32 %94
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"non-digits in datablock size\0A\00"
@.str.2 = [3 x i8] c" \0A\00"
define i32 @read_param_f(i32* nocapture %0, i8* %1, i8* nocapture writeonly %2, i32* nocapture writeonly %3, i8* %4) {
%6 = alloca [256 x i8]
%7 = alloca i8*
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%9 = bitcast i8** %7 to i8*
%10 = call i32 @fgets(i8* %8, i32 256, i32* %0)
%11 = icmp eq i32 %10, 0
br i1 %11, label %52, label %12
12: ; preds = %5, %17
%13 = call i8* @strtok(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %20, label %15
15: ; preds = %12
%16 = load i8, i8* %13
switch i8 %16, label %20 [
i8 33, label %17
i8 10, label %17
]
17: ; preds = %15, %15
%18 = call i32 @fgets(i8* %8, i32 256, i32* %0)
%19 = icmp eq i32 %18, 0
br i1 %19, label %52, label %12
20: ; preds = %15, %12
%21 = call i32 @memcpy(i8* %1, i8* %13, i32 26)
%22 = load i8, i8* %1
%23 = icmp eq i8 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %20, %24
%25 = phi i8 [ %29, %24 ], [ %22, %20 ]
%26 = phi i8* [ %28, %24 ], [ %1, %20 ]
%27 = call signext i8 @tolower(i8 signext %25)
store i8 %27, i8* %26
%28 = getelementptr inbounds i8, i8* %26, i64 1
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %31, label %24
31: ; preds = %24, %20
%32 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%33 = icmp eq i8* %32, null
br i1 %33, label %52, label %34
34: ; preds = %31
%35 = load i8, i8* %32
store i8 %35, i8* %2
%36 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%37 = icmp eq i8* %36, null
br i1 %37, label %52, label %38
38: ; preds = %34
%39 = call i64 @strtol(i8* %36, i8** %7, i32 10)
%40 = trunc i64 %39 to i32
store i32 %40, i32* %3
%41 = load i8*, i8** %7
%42 = load i8, i8* %41
%43 = icmp eq i8 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %38
%45 = load i32, i32* @stderr
%46 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %52
47: ; preds = %38
%48 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%49 = icmp eq i8* %4, null
br i1 %49, label %52, label %50
50: ; preds = %47
%51 = call i32 @memcpy(i8* %4, i8* %48, i32 64)
br label %52
52: ; preds = %17, %5, %47, %34, %31, %50, %44
%53 = phi i32 [ 3, %44 ], [ 0, %50 ], [ 1, %31 ], [ 2, %34 ], [ 4, %47 ], [ -1, %5 ], [ -1, %17 ]
ret i32 %53
}