#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 encfunc1(int);
int /*<<< orphan*/ interleave(int, int, int *, int *);
int /*<<< orphan*/ map_top(int, int, int, int, int, int *, int *);
int revluk(int, int);
int encode_main(int month, int day, int year, int channel, int starttimem,
                int durationm) {
  int j = 0;
  int s1_out = 0;
  int bot3 = 0;
  int top5 = 0;
  int quo = 0;
  int rem = 0;
  int newspaper = 0;
  int cval = 0;
  int tval = 0;
  int big_top5 = 0;
  int big_rem = 0;
  int mtout = 0;
  year = year % 100;
  cval = channel - 1;
  tval = revluk(starttimem, durationm);
  if (tval < 0) {
    return (-1);
  }
  interleave(tval, cval, &big_top5, &big_rem);
  top5 = 0;
  j = 0;
  for (top5 = 0; top5 < 100000; top5++) {
    rem = 0;
    map_top(year, month, day, top5, rem, &mtout, &rem);
    if (mtout == big_top5) {
      break;
    }
  }
  quo = day - 1;
  rem = (big_rem + 320 - rem) % 32;
  bot3 = rem + 1 + (32 * quo);
  s1_out = bot3 + (1000 * top5);
  newspaper = encfunc1(s1_out);
  return (newspaper);
}


x86 assembly (clang, -O0):
<encode_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <revluk@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jge    11eb <encode_main+0xab>
movl   $0xffffffff,-0x4(%rbp)
jmp    12bc <encode_main+0x17c>
mov    -0x40(%rbp),%edi
mov    -0x3c(%rbp),%esi
lea    -0x44(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   1060 <interleave@plt>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x186a0,-0x2c(%rbp)
jge    126c <encode_main+0x12c>
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x34(%rbp),%r8d
lea    -0x4c(%rbp),%r9
lea    -0x34(%rbp),%rax
mov    %rax,(%rsp)
call   1050 <map_top@plt>
mov    -0x4c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jne    1259 <encode_main+0x119>
jmp    126c <encode_main+0x12c>
jmp    125e <encode_main+0x11e>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1213 <encode_main+0xd3>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x48(%rbp),%eax
add    $0x140,%eax
sub    -0x34(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %edx,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    -0x30(%rbp),%ecx
shl    $0x5,%ecx
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
imul   $0x3e8,-0x2c(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <encfunc1@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode_main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %edi,%r15d
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
mov    %r8d,%edi
mov    %r9d,%esi
call   1030 <revluk@plt>
test   %eax,%eax
js     124e <encode_main+0x10e>
movslq %ebp,%rbp
imul   $0x51eb851f,%rbp,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%ebp
add    $0xffffffff,%ebx
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %eax,%edi
mov    %ebx,%esi
call   1060 <interleave@plt>
xor    %ebx,%ebx
lea    0x8(%rsp),%r13
lea    0xc(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movl   $0x0,0x8(%rsp)
mov    %r13,(%rsp)
mov    %ebp,%edi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
xor    %r8d,%r8d
mov    %r12,%r9
call   1050 <map_top@plt>
mov    0xc(%rsp),%eax
cmp    0x14(%rsp),%eax
je     120b <encode_main+0xcb>
add    $0x1,%ebx
cmp    $0x186a0,%ebx
jne    11d0 <encode_main+0x90>
mov    $0x186a0,%ebx
mov    0x10(%rsp),%eax
sub    0x8(%rsp),%eax
lea    0x140(%rax),%ecx
lea    0x15f(%rax),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
and    $0xffffffe0,%edx
neg    %edx
add    %edx,%eax
add    $0x140,%eax
mov    %eax,0x8(%rsp)
shl    $0x5,%r14d
imul   $0x3e8,%ebx,%ecx
add    %r14d,%ecx
lea    (%rcx,%rax,1),%edi
add    $0xffffffe1,%edi
call   1040 <encfunc1@plt>
jmp    1253 <encode_main+0x113>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @encode_main(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 0, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
store i32 0, i32* %17
store i32 0, i32* %18
store i32 0, i32* %19
store i32 0, i32* %20
store i32 0, i32* %21
store i32 0, i32* %22
store i32 0, i32* %23
store i32 0, i32* %24
store i32 0, i32* %25
%26 = load i32, i32* %10
%27 = srem i32 %26, 100
store i32 %27, i32* %10
%28 = load i32, i32* %11
%29 = sub nsw i32 %28, 1
store i32 %29, i32* %21
%30 = load i32, i32* %12
%31 = load i32, i32* %13
%32 = call i32 @revluk(i32 %30, i32 %31)
store i32 %32, i32* %22
%33 = load i32, i32* %22
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %6
store i32 -1, i32* %7
br label %78
36: ; preds = %6
%37 = load i32, i32* %22
%38 = load i32, i32* %21
%39 = call i32 @interleave(i32 %37, i32 %38, i32* %23, i32* %24)
store i32 0, i32* %17
store i32 0, i32* %14
store i32 0, i32* %17
br label %40
40: ; preds = %55, %36
%41 = load i32, i32* %17
%42 = icmp slt i32 %41, 100000
br i1 %42, label %43, label %58
43: ; preds = %40
store i32 0, i32* %19
%44 = load i32, i32* %10
%45 = load i32, i32* %8
%46 = load i32, i32* %9
%47 = load i32, i32* %17
%48 = load i32, i32* %19
%49 = call i32 @map_top(i32 %44, i32 %45, i32 %46, i32 %47, i32 %48, i32* %25, i32* %19)
%50 = load i32, i32* %25
%51 = load i32, i32* %23
%52 = icmp eq i32 %50, %51
br i1 %52, label %53, label %54
53: ; preds = %43
br label %58
54: ; preds = %43
br label %55
55: ; preds = %54
%56 = load i32, i32* %17
%57 = add nsw i32 %56, 1
store i32 %57, i32* %17
br label %40
58: ; preds = %53, %40
%59 = load i32, i32* %9
%60 = sub nsw i32 %59, 1
store i32 %60, i32* %18
%61 = load i32, i32* %24
%62 = add nsw i32 %61, 320
%63 = load i32, i32* %19
%64 = sub nsw i32 %62, %63
%65 = srem i32 %64, 32
store i32 %65, i32* %19
%66 = load i32, i32* %19
%67 = add nsw i32 %66, 1
%68 = load i32, i32* %18
%69 = mul nsw i32 32, %68
%70 = add nsw i32 %67, %69
store i32 %70, i32* %16
%71 = load i32, i32* %16
%72 = load i32, i32* %17
%73 = mul nsw i32 1000, %72
%74 = add nsw i32 %71, %73
store i32 %74, i32* %15
%75 = load i32, i32* %15
%76 = call i32 @encfunc1(i32 %75)
store i32 %76, i32* %20
%77 = load i32, i32* %20
store i32 %77, i32* %7
br label %78
78: ; preds = %58, %35
%79 = load i32, i32* %7
ret i32 %79
}

LLVM IR (-O2):
define i32 @encode_main(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = bitcast i32* %7 to i8*
%12 = bitcast i32* %8 to i8*
store i32 0, i32* %8
%13 = bitcast i32* %9 to i8*
store i32 0, i32* %9
%14 = bitcast i32* %10 to i8*
store i32 0, i32* %10
%15 = srem i32 %2, 100
%16 = tail call i32 @revluk(i32 %4, i32 %5)
%17 = icmp slt i32 %16, 0
br i1 %17, label %43, label %18
18: ; preds = %6
%19 = add nsw i32 %3, -1
%20 = call i32 @interleave(i32 %16, i32 %19, i32* %8, i32* %9)
br label %21
21: ; preds = %18, %27
%22 = phi i32 [ 0, %18 ], [ %28, %27 ]
store i32 0, i32* %7
%23 = call i32 @map_top(i32 %15, i32 %0, i32 %1, i32 %22, i32 0, i32* %10, i32* %7)
%24 = load i32, i32* %10
%25 = load i32, i32* %8
%26 = icmp eq i32 %24, %25
br i1 %26, label %30, label %27
27: ; preds = %21
%28 = add nuw nsw i32 %22, 1
%29 = icmp eq i32 %28, 100000
br i1 %29, label %30, label %21
30: ; preds = %21, %27
%31 = phi i32 [ %22, %21 ], [ 100000, %27 ]
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 320
%34 = load i32, i32* %7
%35 = sub i32 %33, %34
%36 = srem i32 %35, 32
store i32 %36, i32* %7
%37 = shl i32 %1, 5
%38 = mul nsw i32 %31, 1000
%39 = add i32 %37, -31
%40 = add i32 %39, %38
%41 = add i32 %40, %36
%42 = call i32 @encfunc1(i32 %41)
br label %43
43: ; preds = %6, %30
%44 = phi i32 [ %42, %30 ], [ -1, %6 ]
ret i32 %44
}