#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ pkt_header(char *, int, int, int /*<<< orphan*/,
                              int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, char *);
int main(int argc, char **argv) {
  int i;
  char *buffer = malloc(42);
  do {
    for (i = 0; i < 24; i++) {
      scanf("%40c", buffer + 2);
      pkt_header(buffer, i, 1, 0, 0);
      printf("%s", buffer);
    }
  } while (1);
  free(buffer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x2a,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x18,-0x14(%rbp)
jge    11ce <main+0x7e>
mov    -0x20(%rbp),%rsi
add    $0x2,%rsi
lea    0xe6c(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x1,%edx
xor    %r8d,%r8d
mov    %r8d,%ecx
call   1030 <pkt_header@plt>
mov    -0x20(%rbp),%rsi
lea    0xe4a(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117b <main+0x2b>
jmp    11d3 <main+0x83>
mov    $0x1,%al
test   $0x1,%al
jne    1174 <main+0x24>
jmp    11e2 <main+0x92>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x2a,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%r14
add    $0x2,%r14
lea    0xe9d(%rip),%r15
lea    0xe9b(%rip),%r12
nopw   0x0(%rax,%rax,1)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <pkt_header@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x18,%ebp
jne    1180 <main+0x40>
jmp    1170 <main+0x30>

LLVM IR (-O0):
@.str = [5 x i8] c"%40c\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i8* @malloc(i32 42)
store i8* %8, i8** %7
br label %9
9: ; preds = %26, %2
store i32 0, i32* %6
br label %10
10: ; preds = %22, %9
%11 = load i32, i32* %6
%12 = icmp slt i32 %11, 24
br i1 %12, label %13, label %25
13: ; preds = %10
%14 = load i8*, i8** %7
%15 = getelementptr inbounds i8, i8* %14, i64 2
%16 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %7
%18 = load i32, i32* %6
%19 = call i32 @pkt_header(i8* %17, i32 %18, i32 1, i32 0, i32 0)
%20 = load i8*, i8** %7
%21 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %13
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
br label %10
25: ; preds = %10
br label %26
26: ; preds = %25
br i1 true, label %9, label %27
27: ; preds = %26
%28 = load i8*, i8** %7
%29 = call i32 @free(i8* %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%40c\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(42) i8* @malloc(i32 42)
%4 = getelementptr inbounds i8, i8* %3, i64 2
br label %5
5: ; preds = %6, %2
br label %6
6: ; preds = %5, %6
%7 = phi i32 [ 0, %5 ], [ %11, %6 ]
%8 = tail call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %4)
%9 = tail call i32 @pkt_header(i8* %3, i32 %7, i32 1, i32 0, i32 0)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%11 = add nuw nsw i32 %7, 1
%12 = icmp eq i32 %11, 24
br i1 %12, label %5, label %6
}