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

/* Variables and functions */
int /*<<< orphan*/ dump_hex(unsigned char *, int);
unsigned char my_fgetc(int /*<<< orphan*/ *);
void skip_to_at(FILE *fin, unsigned char code, int print) {
  int i;
  unsigned char skip_data[65536];
  skip_data[0] = code;
  for (i = 1; (skip_data[i] = my_fgetc(fin)) != '@' && i < sizeof(skip_data);
       i++)
    ;
  if (print)
    dump_hex(skip_data, i + 1);
}


x86 assembly (clang, -O0):
<skip_to_at>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10030,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x9(%rbp),%al
mov    %al,-0x10020(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <my_fgetc@plt>
movslq -0x14(%rbp),%rcx
mov    %al,-0x10020(%rbp,%rcx,1)
movzbl %al,%ecx
xor    %eax,%eax
cmp    $0x40,%ecx
mov    %al,-0x10021(%rbp)
je     1183 <skip_to_at+0x63>
movslq -0x14(%rbp),%rax
cmp    $0x10000,%rax
setb   %al
mov    %al,-0x10021(%rbp)
mov    -0x10021(%rbp),%al
test   $0x1,%al
jne    1196 <skip_to_at+0x76>
jmp    11a9 <skip_to_at+0x89>
jmp    119b <skip_to_at+0x7b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1148 <skip_to_at+0x28>
cmpl   $0x0,-0x10(%rbp)
je     11c5 <skip_to_at+0xa5>
lea    -0x10020(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
call   1040 <dump_hex@plt>
add    $0x10030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_to_at>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10000,%rsp
mov    %edx,%r14d
mov    %rdi,%rbx
mov    %sil,(%rsp)
mov    $0x1,%ebp
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <my_fgetc@plt>
mov    %al,(%rsp,%rbp,1)
lea    0x1(%rbp),%rsi
cmp    $0x40,%al
je     115f <skip_to_at+0x3f>
cmp    $0x10000,%rbp
mov    %rsi,%rbp
jb     1140 <skip_to_at+0x20>
test   %r14d,%r14d
je     116c <skip_to_at+0x4c>
mov    %rsp,%rdi
call   1040 <dump_hex@plt>
add    $0x10000,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @skip_to_at(i32* %0, i8 zeroext %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca [65536 x i8]
store i32* %0, i32** %4
store i8 %1, i8* %5
store i32 %2, i32* %6
%9 = load i8, i8* %5
%10 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 0
store i8 %9, i8* %10
store i32 1, i32* %7
br label %11
11: ; preds = %26, %3
%12 = load i32*, i32** %4
%13 = call zeroext i8 @my_fgetc(i32* %12)
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 %15
store i8 %13, i8* %16
%17 = zext i8 %13 to i32
%18 = icmp ne i32 %17, 64
br i1 %18, label %19, label %23
19: ; preds = %11
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = icmp ult i64 %21, 65536
br label %23
23: ; preds = %19, %11
%24 = phi i1 [ false, %11 ], [ %22, %19 ]
br i1 %24, label %25, label %29
25: ; preds = %23
br label %26
26: ; preds = %25
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %11
29: ; preds = %23
%30 = load i32, i32* %6
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %29
%33 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 0
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
%36 = call i32 @dump_hex(i8* %33, i32 %35)
br label %37
37: ; preds = %32, %29
ret void
}

LLVM IR (-O2):
define void @skip_to_at(i32* %0, i8 zeroext %1, i32 %2) {
%4 = alloca [65536 x i8]
%5 = getelementptr inbounds [65536 x i8], [65536 x i8]* %4, i64 0, i64 0
store i8 %1, i8* %5
br label %6
6: ; preds = %6, %3
%7 = phi i64 [ %13, %6 ], [ 1, %3 ]
%8 = tail call zeroext i8 @my_fgetc(i32* %0)
%9 = getelementptr inbounds [65536 x i8], [65536 x i8]* %4, i64 0, i64 %7
store i8 %8, i8* %9
%10 = icmp ne i8 %8, 64
%11 = icmp ult i64 %7, 65536
%12 = select i1 %10, i1 %11, i1 false
%13 = add nuw nsw i64 %7, 1
br i1 %12, label %6, label %14
14: ; preds = %6
%15 = icmp eq i32 %2, 0
br i1 %15, label %20, label %16
16: ; preds = %14
%17 = trunc i64 %7 to i32
%18 = add nuw nsw i32 %17, 1
%19 = call i32 @dump_hex(i8* %5, i32 %18)
br label %20
20: ; preds = %16, %14
ret void
}