#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*/ O_RDONLY;
int /*<<< orphan*/ STDOUT_FILENO;
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(unsigned char *);
unsigned short htons(unsigned short);
unsigned char *malloc(unsigned short);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned short *, int);
int /*<<< orphan*/ memset(unsigned char *, int, unsigned short);
int open(char *, int /*<<< orphan*/);
int read(int, unsigned char *, int);
int /*<<< orphan*/ stamp_ts(unsigned long long, unsigned char *);
int /*<<< orphan*/ stderr;
unsigned long long strtoull(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ write(int /*<<< orphan*/, unsigned char *, unsigned short);
int main(int argc, char *argv[]) {
  unsigned long long int pts_stamp = 3600;
  unsigned char *pes_packet;
  int byte_read = 0;
  int file_es = 0;
  int packet_index = 0;
  int txtunitperpes = 0;
  int pts_increment = 3600;
  if (argc > 2) {
    file_es = open(argv[1], O_RDONLY);
    txtunitperpes = atoi(argv[2]);
  }
  if (argc > 3) {
    pts_stamp = strtoull(argv[3], 0, 0);
  }
  if (argc > 4) {
    pts_increment = atoi(argv[4]);
  }
  if (file_es == 0) {
    fprintf(stderr, "Usage: 'txt2pes txt.es txt_units_per_pes_packet "
                    "[pts_offset [pts_increment]] > pes'\n");
    fprintf(
        stderr,
        "txt_unit_per_pes_packet increase bit rate, minimum is 1, max is 24\n");
    fprintf(stderr, "Default pts_offset and increment is 3600, means 2 fields "
                    "or 1 frame\n");
    fprintf(stderr, "txt.es is 46 byte units of ebu teletext coding\n");
    return 2;
  }
  unsigned short pes_size = ((txtunitperpes + 1) * 46);
  pes_packet = malloc(pes_size);
  fprintf(stderr, "pes packet size without 6 byte header is %d\n",
          pes_size - 6);
  memset(pes_packet, 0xFF, pes_size);
  pes_packet[0] = 0x00;
  pes_packet[1] = 0x00;
  pes_packet[2] = 0x01;
  pes_packet[3] = 0xBD;
  unsigned short temp = htons(pes_size - 6);
  memcpy(pes_packet + 4, &temp, sizeof(unsigned short));
  pes_packet[6] = 0x8F;
  pes_packet[7] = 0x80;
  pes_packet[8] = 0x24;
  pes_packet[45] = 0x10;
  packet_index = 46;
  byte_read = 1;
  while (byte_read) {
    byte_read = read(file_es, pes_packet + packet_index, 46);
    if (byte_read != 0) {
      packet_index += 46;
      if (packet_index == pes_size) {
        stamp_ts(pts_stamp, pes_packet + 9);
        write(STDOUT_FILENO, pes_packet, pes_size);
        pts_stamp += pts_increment;
        packet_index = 46;
      }
    } else {
      close(file_es);
      file_es = open(argv[1], O_RDONLY);
      byte_read = 1;
    }
  }
  if (pes_packet) {
    free(pes_packet);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0xe10,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0xe10,-0x34(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1244 <main+0x74>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2db6(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    1263 <main+0x93>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1090 <strtoull@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x4,-0x8(%rbp)
jle    127d <main+0xad>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    12ef <main+0x11f>
mov    0x2d42(%rip),%rax
mov    (%rax),%edi
lea    0xd69(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
lea    0xda7(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
lea    0xdd4(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2cfd(%rip),%rax
mov    (%rax),%edi
lea    0xe02(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1480 <main+0x2b0>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
imul   $0x2e,%eax,%eax
mov    %ax,-0x36(%rbp)
movzwl -0x36(%rbp),%edi
call   10d0 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    0x2cc0(%rip),%rax
mov    (%rax),%edi
movzwl -0x36(%rbp),%edx
sub    $0x6,%edx
lea    0xdee(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x36(%rbp),%ax
movzwl %ax,%edx
mov    $0xff,%esi
call   1060 <memset@plt>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x20(%rbp),%rax
movb   $0x1,0x2(%rax)
mov    -0x20(%rbp),%rax
movb   $0xbd,0x3(%rax)
movzwl -0x36(%rbp),%eax
sub    $0x6,%eax
movzwl %ax,%edi
call   1050 <htons@plt>
mov    %ax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x4,%rdi
lea    -0x38(%rbp),%rsi
mov    $0x2,%edx
call   10b0 <memcpy@plt>
mov    -0x20(%rbp),%rax
movb   $0x8f,0x6(%rax)
mov    -0x20(%rbp),%rax
movb   $0x80,0x7(%rax)
mov    -0x20(%rbp),%rax
movb   $0x24,0x8(%rax)
mov    -0x20(%rbp),%rax
movb   $0x10,0x2d(%rax)
movl   $0x2e,-0x2c(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1465 <main+0x295>
mov    -0x28(%rbp),%edi
mov    -0x20(%rbp),%rsi
movslq -0x2c(%rbp),%rax
add    %rax,%rsi
mov    $0x2e,%edx
call   1080 <read@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1438 <main+0x268>
mov    -0x2c(%rbp),%eax
add    $0x2e,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
movzwl -0x36(%rbp),%ecx
cmp    %ecx,%eax
jne    1433 <main+0x263>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x9,%rsi
call   10c0 <stamp_ts@plt>
mov    0x2bdf(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rsi
movzwl -0x36(%rbp),%edx
call   1040 <write@plt>
movslq -0x34(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x2e,-0x2c(%rbp)
jmp    1460 <main+0x290>
mov    -0x28(%rbp),%edi
call   1070 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2b91(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
mov    %eax,-0x28(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    13b2 <main+0x1e2>
cmpq   $0x0,-0x20(%rbp)
je     1479 <main+0x2a9>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x3,%edi
jl     1356 <main+0x196>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
mov    0x2df9(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,%r12d
mov    0x10(%rbx),%rdi
call   10e0 <atoi@plt>
mov    %eax,%r14d
mov    $0xe10,%eax
mov    %rax,0x8(%rsp)
cmp    $0x3,%ebp
jne    1214 <main+0x54>
mov    $0xe10,%r15d
jmp    1239 <main+0x79>
mov    0x18(%rbx),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <strtoull@plt>
mov    %rax,%r15
cmp    $0x5,%ebp
jb     1239 <main+0x79>
mov    0x20(%rbx),%rdi
call   10e0 <atoi@plt>
cltq
mov    %rax,0x8(%rsp)
test   %r12d,%r12d
je     1356 <main+0x196>
mov    %rbx,0x10(%rsp)
imul   $0x2e,%r14d,%eax
add    $0x2e,%eax
movzwl %ax,%ebx
mov    %ebx,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbp
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    -0x6(%rbx),%r13d
lea    0xe9f(%rip),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %rbp,%rdi
mov    $0xff,%esi
mov    %ebx,%edx
call   1050 <memset@plt>
movl   $0xbd010000,0x0(%rbp)
movzwl %r13w,%edi
call   1040 <htons@plt>
mov    %ax,0x6(%rsp)
lea    0x4(%rbp),%rdi
lea    0x6(%rsp),%rsi
mov    $0x2,%edx
call   10a0 <memcpy@plt>
movw   $0x808f,0x6(%rbp)
movb   $0x24,0x8(%rbp)
movb   $0x10,0x2d(%rbp)
lea    0x9(%rbp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x2e,%r14d
jmp    1302 <main+0x142>
nopl   0x0(%rax,%rax,1)
mov    %r12d,%edi
call   1060 <close@plt>
mov    0x10(%rsp),%rax
mov    0x8(%rax),%rdi
mov    0x2ce8(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,%r12d
movslq %r14d,%r14
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r14,%rbp,1),%rsi
mov    %r12d,%edi
mov    $0x2e,%edx
call   1070 <read@plt>
test   %eax,%eax
je     12e0 <main+0x120>
add    $0x2e,%r14
cmp    %r14d,%ebx
jne    1310 <main+0x150>
mov    %r15,%rdi
mov    %r13,%rsi
call   10b0 <stamp_ts@plt>
mov    0x2cb0(%rip),%rax
mov    (%rax),%edi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1030 <write@plt>
add    0x8(%rsp),%r15
jmp    12d0 <main+0x110>
mov    0x2c73(%rip),%rbx
mov    (%rbx),%edi
lea    0xc9a(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%rbx),%edi
lea    0xcdf(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd13(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd48(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x2,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [85 x i8] c"Usage: 'txt2pes txt.es txt_units_per_pes_packet [pts_offset [pts_increment]] > pes'\0A\00"
@.str.1 = [68 x i8] c"txt_unit_per_pes_packet increase bit rate, minimum is 1, max is 24\0A\00"
@.str.2 = [69 x i8] c"Default pts_offset and increment is 3600, means 2 fields or 1 frame\0A\00"
@.str.3 = [48 x i8] c"txt.es is 46 byte units of ebu teletext coding\0A\00"
@.str.4 = [45 x i8] c"pes packet size without 6 byte header is %d\0A\00"
@STDOUT_FILENO = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i16
%14 = alloca i16
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 3600, i64* %6
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 3600, i32* %12
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 2
br i1 %16, label %17, label %27
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = load i32, i32* @O_RDONLY
%22 = call i32 @open(i8* %20, i32 %21)
store i32 %22, i32* %9
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %11
br label %27
27: ; preds = %17, %2
%28 = load i32, i32* %4
%29 = icmp sgt i32 %28, 3
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 3
%33 = load i8*, i8** %32
%34 = call i64 @strtoull(i8* %33, i32 0, i32 0)
store i64 %34, i64* %6
br label %35
35: ; preds = %30, %27
%36 = load i32, i32* %4
%37 = icmp sgt i32 %36, 4
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 4
%41 = load i8*, i8** %40
%42 = call i32 @atoi(i8* %41)
store i32 %42, i32* %12
br label %43
43: ; preds = %38, %35
%44 = load i32, i32* %9
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %55
46: ; preds = %43
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str, i64 0, i64 0))
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0))
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.2, i64 0, i64 0))
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
store i32 2, i32* %3
br label %143
55: ; preds = %43
%56 = load i32, i32* %11
%57 = add nsw i32 %56, 1
%58 = mul nsw i32 %57, 46
%59 = trunc i32 %58 to i16
store i16 %59, i16* %13
%60 = load i16, i16* %13
%61 = call i8* @malloc(i16 zeroext %60)
store i8* %61, i8** %7
%62 = load i32, i32* @stderr
%63 = load i16, i16* %13
%64 = zext i16 %63 to i32
%65 = sub nsw i32 %64, 6
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i32 %65)
%67 = load i8*, i8** %7
%68 = load i16, i16* %13
%69 = call i32 @memset(i8* %67, i32 255, i16 zeroext %68)
%70 = load i8*, i8** %7
%71 = getelementptr inbounds i8, i8* %70, i64 0
store i8 0, i8* %71
%72 = load i8*, i8** %7
%73 = getelementptr inbounds i8, i8* %72, i64 1
store i8 0, i8* %73
%74 = load i8*, i8** %7
%75 = getelementptr inbounds i8, i8* %74, i64 2
store i8 1, i8* %75
%76 = load i8*, i8** %7
%77 = getelementptr inbounds i8, i8* %76, i64 3
store i8 -67, i8* %77
%78 = load i16, i16* %13
%79 = zext i16 %78 to i32
%80 = sub nsw i32 %79, 6
%81 = trunc i32 %80 to i16
%82 = call zeroext i16 @htons(i16 zeroext %81)
store i16 %82, i16* %14
%83 = load i8*, i8** %7
%84 = getelementptr inbounds i8, i8* %83, i64 4
%85 = call i32 @memcpy(i8* %84, i16* %14, i32 2)
%86 = load i8*, i8** %7
%87 = getelementptr inbounds i8, i8* %86, i64 6
store i8 -113, i8* %87
%88 = load i8*, i8** %7
%89 = getelementptr inbounds i8, i8* %88, i64 7
store i8 -128, i8* %89
%90 = load i8*, i8** %7
%91 = getelementptr inbounds i8, i8* %90, i64 8
store i8 36, i8* %91
%92 = load i8*, i8** %7
%93 = getelementptr inbounds i8, i8* %92, i64 45
store i8 16, i8* %93
store i32 46, i32* %10
store i32 1, i32* %8
br label %94
94: ; preds = %135, %55
%95 = load i32, i32* %8
%96 = icmp ne i32 %95, 0
br i1 %96, label %97, label %136
97: ; preds = %94
%98 = load i32, i32* %9
%99 = load i8*, i8** %7
%100 = load i32, i32* %10
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8, i8* %99, i64 %101
%103 = call i32 @read(i32 %98, i8* %102, i32 46)
store i32 %103, i32* %8
%104 = load i32, i32* %8
%105 = icmp ne i32 %104, 0
br i1 %105, label %106, label %127
106: ; preds = %97
%107 = load i32, i32* %10
%108 = add nsw i32 %107, 46
store i32 %108, i32* %10
%109 = load i32, i32* %10
%110 = load i16, i16* %13
%111 = zext i16 %110 to i32
%112 = icmp eq i32 %109, %111
br i1 %112, label %113, label %126
113: ; preds = %106
%114 = load i64, i64* %6
%115 = load i8*, i8** %7
%116 = getelementptr inbounds i8, i8* %115, i64 9
%117 = call i32 @stamp_ts(i64 %114, i8* %116)
%118 = load i32, i32* @STDOUT_FILENO
%119 = load i8*, i8** %7
%120 = load i16, i16* %13
%121 = call i32 @write(i32 %118, i8* %119, i16 zeroext %120)
%122 = load i32, i32* %12
%123 = sext i32 %122 to i64
%124 = load i64, i64* %6
%125 = add i64 %124, %123
store i64 %125, i64* %6
store i32 46, i32* %10
br label %126
126: ; preds = %113, %106
br label %135
127: ; preds = %97
%128 = load i32, i32* %9
%129 = call i32 @close(i32 %128)
%130 = load i8**, i8*** %5
%131 = getelementptr inbounds i8*, i8** %130, i64 1
%132 = load i8*, i8** %131
%133 = load i32, i32* @O_RDONLY
%134 = call i32 @open(i8* %132, i32 %133)
store i32 %134, i32* %9
store i32 1, i32* %8
br label %135
135: ; preds = %127, %126
br label %94
136: ; preds = %94
%137 = load i8*, i8** %7
%138 = icmp ne i8* %137, null
br i1 %138, label %139, label %142
139: ; preds = %136
%140 = load i8*, i8** %7
%141 = call i32 @free(i8* %140)
br label %142
142: ; preds = %139, %136
store i32 0, i32* %3
br label %143
143: ; preds = %142, %46
%144 = load i32, i32* %3
ret i32 %144
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [85 x i8] c"Usage: 'txt2pes txt.es txt_units_per_pes_packet [pts_offset [pts_increment]] > pes'\0A\00"
@.str.1 = [68 x i8] c"txt_unit_per_pes_packet increase bit rate, minimum is 1, max is 24\0A\00"
@.str.2 = [69 x i8] c"Default pts_offset and increment is 3600, means 2 fields or 1 frame\0A\00"
@.str.3 = [48 x i8] c"txt.es is 46 byte units of ebu teletext coding\0A\00"
@.str.4 = [45 x i8] c"pes packet size without 6 byte header is %d\0A\00"
@STDOUT_FILENO = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i16
%4 = icmp sgt i32 %0, 2
br i1 %4, label %5, label %31
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = load i32, i32* @O_RDONLY
%9 = tail call i32 @open(i8* %7, i32 %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = trunc i32 %12 to i16
%14 = mul i16 %13, 46
%15 = add i16 %14, 46
%16 = icmp eq i32 %0, 3
br i1 %16, label %27, label %17
17: ; preds = %5
%18 = getelementptr inbounds i8*, i8** %1, i64 3
%19 = load i8*, i8** %18
%20 = tail call i64 @strtoull(i8* %19, i32 0, i32 0)
%21 = icmp ugt i32 %0, 4
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = getelementptr inbounds i8*, i8** %1, i64 4
%24 = load i8*, i8** %23
%25 = tail call i32 @atoi(i8* %24)
%26 = sext i32 %25 to i64
br label %27
27: ; preds = %5, %22, %17
%28 = phi i64 [ %20, %22 ], [ %20, %17 ], [ 3600, %5 ]
%29 = phi i64 [ %26, %22 ], [ 3600, %17 ], [ 3600, %5 ]
%30 = icmp eq i32 %9, 0
br i1 %30, label %31, label %40
31: ; preds = %2, %27
%32 = load i32, i32* @stderr
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str, i64 0, i64 0))
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.1, i64 0, i64 0))
%36 = load i32, i32* @stderr
%37 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.2, i64 0, i64 0))
%38 = load i32, i32* @stderr
%39 = tail call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
ret i32 2
40: ; preds = %27
%41 = tail call i8* @malloc(i16 zeroext %15)
%42 = load i32, i32* @stderr
%43 = zext i16 %15 to i32
%44 = add nsw i32 %43, -6
%45 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i32 %44)
%46 = tail call i32 @memset(i8* %41, i32 255, i16 zeroext %15)
store i8 0, i8* %41
%47 = getelementptr inbounds i8, i8* %41, i64 1
store i8 0, i8* %47
%48 = getelementptr inbounds i8, i8* %41, i64 2
store i8 1, i8* %48
%49 = getelementptr inbounds i8, i8* %41, i64 3
store i8 -67, i8* %49
%50 = bitcast i16* %3 to i8*
%51 = trunc i32 %44 to i16
%52 = tail call zeroext i16 @htons(i16 zeroext %51)
store i16 %52, i16* %3
%53 = getelementptr inbounds i8, i8* %41, i64 4
%54 = call i32 @memcpy(i8* %53, i16* %3, i32 2)
%55 = getelementptr inbounds i8, i8* %41, i64 6
store i8 -113, i8* %55
%56 = getelementptr inbounds i8, i8* %41, i64 7
store i8 -128, i8* %56
%57 = getelementptr inbounds i8, i8* %41, i64 8
store i8 36, i8* %57
%58 = getelementptr inbounds i8, i8* %41, i64 45
store i8 16, i8* %58
%59 = getelementptr inbounds i8, i8* %41, i64 9
br label %60
60: ; preds = %75, %40
%61 = phi i64 [ %79, %75 ], [ %28, %40 ]
%62 = phi i32 [ %64, %75 ], [ %9, %40 ]
br label %63
63: ; preds = %60, %80
%64 = phi i32 [ %62, %60 ], [ %84, %80 ]
%65 = phi i32 [ 46, %60 ], [ %67, %80 ]
br label %66
66: ; preds = %63, %72
%67 = phi i32 [ %73, %72 ], [ %65, %63 ]
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %41, i64 %68
%70 = call i32 @read(i32 %64, i8* %69, i32 46)
%71 = icmp eq i32 %70, 0
br i1 %71, label %80, label %72
72: ; preds = %66
%73 = add nsw i32 %67, 46
%74 = icmp eq i32 %73, %43
br i1 %74, label %75, label %66
75: ; preds = %72
%76 = call i32 @stamp_ts(i64 %61, i8* %59)
%77 = load i32, i32* @STDOUT_FILENO
%78 = call i32 @write(i32 %77, i8* %41, i16 zeroext %15)
%79 = add i64 %61, %29
br label %60
80: ; preds = %66
%81 = call i32 @close(i32 %64)
%82 = load i8*, i8** %6
%83 = load i32, i32* @O_RDONLY
%84 = call i32 @open(i8* %82, i32 %83)
br label %63
}