#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 int32_t;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ memset(char *, int, int);
int ntohl(int);
int32_t io_int_record_date(int32_t *fmap, int32_t pos, int32_t size,
                           char *(date[132])) {
  int32_t wtype = 0;
  const int32_t doff = 5;
  int32_t dlen = 0;
  int32_t i = 0;
  if (fmap == NULL) {
    return (EXIT_FAILURE);
  }
  wtype = ntohl(fmap[pos + 2]);
  if ((wtype == 180) || (wtype == 220) || (wtype == 140)) {
    memset(*date, 32, 132);
    return (EXIT_SUCCESS);
  }
  if (size >= doff) {
    dlen = ntohl(fmap[pos + doff]);
  } else {
    return (EXIT_FAILURE);
  }
  if (dlen > 1) {
    memset(*date, 32, 132);
    for (i = 0; i < dlen; ++i) {
      (*date)[i] = (char)ntohl(fmap[pos + doff + 1 + i]);
    }
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<io_int_record_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x5,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116e <io_int_record_date+0x4e>
mov    0x2e7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1289 <io_int_record_date+0x169>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <ntohl@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xb4,-0x24(%rbp)
je     11ad <io_int_record_date+0x8d>
cmpl   $0xdc,-0x24(%rbp)
je     11ad <io_int_record_date+0x8d>
cmpl   $0x8c,-0x24(%rbp)
jne    11d4 <io_int_record_date+0xb4>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    $0x20,%esi
mov    $0x84,%edx
call   1030 <memset@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1289 <io_int_record_date+0x169>
cmpl   $0x5,-0x18(%rbp)
jl     11fb <io_int_record_date+0xdb>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x5,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <ntohl@plt>
mov    %eax,-0x2c(%rbp)
jmp    120c <io_int_record_date+0xec>
mov    0x2dde(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1289 <io_int_record_date+0x169>
cmpl   $0x1,-0x2c(%rbp)
jle    127d <io_int_record_date+0x15d>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    $0x20,%esi
mov    $0x84,%edx
call   1030 <memset@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1278 <io_int_record_date+0x158>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x5,%ecx
add    $0x1,%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <ntohl@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movslq -0x30(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1233 <io_int_record_date+0x113>
jmp    127d <io_int_record_date+0x15d>
mov    0x2d54(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<io_int_record_date>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2eae(%rip),%r13
test   %rdi,%rdi
je     117b <io_int_record_date+0x5b>
mov    %rcx,%r14
mov    %edx,%r15d
mov    %rdi,%rbx
movslq %esi,%r12
mov    0x8(%rdi,%r12,4),%edi
call   1040 <ntohl@plt>
cmp    $0x8c,%eax
je     1162 <io_int_record_date+0x42>
cmp    $0xdc,%eax
je     1162 <io_int_record_date+0x42>
cmp    $0xb4,%eax
jne    118e <io_int_record_date+0x6e>
mov    (%r14),%rdi
mov    $0x20,%esi
mov    $0x84,%edx
call   1030 <memset@plt>
mov    0x2e5d(%rip),%r13
mov    0x0(%r13),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x5,%r15d
jl     117b <io_int_record_date+0x5b>
mov    0x14(%rbx,%r12,4),%edi
call   1040 <ntohl@plt>
mov    0x2e33(%rip),%r13
cmp    $0x2,%eax
jl     117b <io_int_record_date+0x5b>
mov    %eax,%r15d
mov    (%r14),%rdi
mov    $0x20,%esi
mov    $0x84,%edx
call   1030 <memset@plt>
mov    %r15d,%r15d
lea    (%rbx,%r12,4),%rbx
add    $0x18,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%rbx,%rbp,4),%edi
call   1040 <ntohl@plt>
mov    (%r14),%rcx
mov    %al,(%rcx,%rbp,1)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    11d0 <io_int_record_date+0xb0>
jmp    117b <io_int_record_date+0x5b>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @io_int_record_date(i32* %0, i32 %1, i32 %2, i8** %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8** %3, i8*** %9
store i32 0, i32* %10
store i32 5, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
%14 = load i32*, i32** %6
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %4
%17 = load i32, i32* @EXIT_FAILURE
store i32 %17, i32* %5
br label %86
18: ; preds = %4
%19 = load i32*, i32** %6
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %19, i64 %22
%24 = load i32, i32* %23
%25 = call i32 @ntohl(i32 %24)
store i32 %25, i32* %10
%26 = load i32, i32* %10
%27 = icmp eq i32 %26, 180
br i1 %27, label %34, label %28
28: ; preds = %18
%29 = load i32, i32* %10
%30 = icmp eq i32 %29, 220
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = load i32, i32* %10
%33 = icmp eq i32 %32, 140
br i1 %33, label %34, label %39
34: ; preds = %31, %28, %18
%35 = load i8**, i8*** %9
%36 = load i8*, i8** %35
%37 = call i32 @memset(i8* %36, i32 32, i32 132)
%38 = load i32, i32* @EXIT_SUCCESS
store i32 %38, i32* %5
br label %86
39: ; preds = %31
%40 = load i32, i32* %8
%41 = icmp sge i32 %40, 5
br i1 %41, label %42, label %50
42: ; preds = %39
%43 = load i32*, i32** %6
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 5
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %43, i64 %46
%48 = load i32, i32* %47
%49 = call i32 @ntohl(i32 %48)
store i32 %49, i32* %12
br label %52
50: ; preds = %39
%51 = load i32, i32* @EXIT_FAILURE
store i32 %51, i32* %5
br label %86
52: ; preds = %42
%53 = load i32, i32* %12
%54 = icmp sgt i32 %53, 1
br i1 %54, label %55, label %84
55: ; preds = %52
%56 = load i8**, i8*** %9
%57 = load i8*, i8** %56
%58 = call i32 @memset(i8* %57, i32 32, i32 132)
store i32 0, i32* %13
br label %59
59: ; preds = %80, %55
%60 = load i32, i32* %13
%61 = load i32, i32* %12
%62 = icmp slt i32 %60, %61
br i1 %62, label %63, label %83
63: ; preds = %59
%64 = load i32*, i32** %6
%65 = load i32, i32* %7
%66 = add nsw i32 %65, 5
%67 = add nsw i32 %66, 1
%68 = load i32, i32* %13
%69 = add nsw i32 %67, %68
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32, i32* %64, i64 %70
%72 = load i32, i32* %71
%73 = call i32 @ntohl(i32 %72)
%74 = trunc i32 %73 to i8
%75 = load i8**, i8*** %9
%76 = load i8*, i8** %75
%77 = load i32, i32* %13
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8, i8* %76, i64 %78
store i8 %74, i8* %79
br label %80
80: ; preds = %63
%81 = load i32, i32* %13
%82 = add nsw i32 %81, 1
store i32 %82, i32* %13
br label %59
83: ; preds = %59
br label %84
84: ; preds = %83, %52
%85 = load i32, i32* @EXIT_SUCCESS
store i32 %85, i32* %5
br label %86
86: ; preds = %84, %50, %34, %16
%87 = load i32, i32* %5
ret i32 %87
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @io_int_record_date(i32* %0, i32 %1, i32 %2, i8** nocapture %3) {
%5 = icmp eq i32* %0, null
br i1 %5, label %41, label %6
6: ; preds = %4
%7 = add nsw i32 %1, 2
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* %0, i64 %8
%10 = load i32, i32* %9
%11 = tail call i32 @ntohl(i32 %10)
switch i32 %11, label %15 [
i32 220, label %12
i32 180, label %12
i32 140, label %12
]
12: ; preds = %6, %6, %6
%13 = load i8*, i8** %3
%14 = tail call i32 @memset(i8* %13, i32 32, i32 132)
br label %41
15: ; preds = %6
%16 = icmp sgt i32 %2, 4
br i1 %16, label %17, label %41
17: ; preds = %15
%18 = add nsw i32 %1, 5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %0, i64 %19
%21 = load i32, i32* %20
%22 = tail call i32 @ntohl(i32 %21)
%23 = icmp sgt i32 %22, 1
br i1 %23, label %24, label %41
24: ; preds = %17
%25 = load i8*, i8** %3
%26 = tail call i32 @memset(i8* %25, i32 32, i32 132)
%27 = add nsw i32 %1, 6
%28 = sext i32 %27 to i64
%29 = zext i32 %22 to i64
br label %30
30: ; preds = %24, %30
%31 = phi i64 [ 0, %24 ], [ %39, %30 ]
%32 = add nsw i64 %31, %28
%33 = getelementptr inbounds i32, i32* %0, i64 %32
%34 = load i32, i32* %33
%35 = tail call i32 @ntohl(i32 %34)
%36 = trunc i32 %35 to i8
%37 = load i8*, i8** %3
%38 = getelementptr inbounds i8, i8* %37, i64 %31
store i8 %36, i8* %38
%39 = add nuw nsw i64 %31, 1
%40 = icmp eq i64 %39, %29
br i1 %40, label %41, label %30
41: ; preds = %30, %17, %15, %4, %12
%42 = phi i32* [ @EXIT_SUCCESS, %12 ], [ @EXIT_FAILURE, %4 ], [ @EXIT_FAILURE, %15 ], [ @EXIT_SUCCESS, %17 ], [ @EXIT_SUCCESS, %30 ]
%43 = load i32, i32* %42
ret i32 %43
}