#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*/ FILE;

/* Variables and functions */
int getushort(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, ...);
void ShowAttach(FILE *ttf) {
  int format = getushort(ttf);
  int x = getushort(ttf);
  int y = getushort(ttf);
  if (format == 1)
    printf("Attach at (%d,%d)\n", x, y);
  else if (format == 2)
    printf("Attach at (%d,%d pt=%d)\n", x, y, getushort(ttf));
  else if (format == 3) {
    printf("Attach at (%d,%d XDeviceOff=%d", x, y, getushort(ttf));
    printf(" YDeviceOff=%d)\n", getushort(ttf));
  } else
    printf("Unknown attachment format %d\n", format);
}


x86 assembly (clang, -O0):
<ShowAttach>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getushort@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getushort@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getushort@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1173 <ShowAttach+0x53>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121b <ShowAttach+0xfb>
cmpl   $0x2,-0xc(%rbp)
jne    11ad <ShowAttach+0x8d>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getushort@plt>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    %eax,%ecx
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1216 <ShowAttach+0xf6>
cmpl   $0x3,-0xc(%rbp)
jne    1200 <ShowAttach+0xe0>
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getushort@plt>
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    %eax,%ecx
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <getushort@plt>
mov    %eax,%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1211 <ShowAttach+0xf1>
mov    -0xc(%rbp),%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1216 <ShowAttach+0xf6>
jmp    121b <ShowAttach+0xfb>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ShowAttach>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <getushort@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <getushort@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1040 <getushort@plt>
mov    %eax,%r15d
cmp    $0x3,%ebp
je     1174 <ShowAttach+0x54>
cmp    $0x2,%ebp
je     11a5 <ShowAttach+0x85>
cmp    $0x1,%ebp
jne    11cd <ShowAttach+0xad>
lea    0xea3(%rip),%rdi
mov    %r14d,%esi
mov    %r15d,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <getushort@plt>
lea    0xea9(%rip),%rdi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <getushort@plt>
lea    0xeaa(%rip),%rdi
mov    %eax,%esi
jmp    11d6 <ShowAttach+0xb6>
mov    %rbx,%rdi
call   1040 <getushort@plt>
lea    0xe5f(%rip),%rdi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %eax,%ecx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>
lea    0xe88(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"Attach at (%d,%d)\0A\00"
@.str.1 = [25 x i8] c"Attach at (%d,%d pt=%d)\0A\00"
@.str.2 = [31 x i8] c"Attach at (%d,%d XDeviceOff=%d\00"
@.str.3 = [17 x i8] c" YDeviceOff=%d)\0A\00"
@.str.4 = [30 x i8] c"Unknown attachment format %d\0A\00"
define void @ShowAttach(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
%6 = load i32*, i32** %2
%7 = call i32 @getushort(i32* %6)
store i32 %7, i32* %3
%8 = load i32*, i32** %2
%9 = call i32 @getushort(i32* %8)
store i32 %9, i32* %4
%10 = load i32*, i32** %2
%11 = call i32 @getushort(i32* %10)
store i32 %11, i32* %5
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %18
14: ; preds = %1
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16)
br label %44
18: ; preds = %1
%19 = load i32, i32* %3
%20 = icmp eq i32 %19, 2
br i1 %20, label %21, label %27
21: ; preds = %18
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = load i32*, i32** %2
%25 = call i32 @getushort(i32* %24)
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23, i32 %25)
br label %43
27: ; preds = %18
%28 = load i32, i32* %3
%29 = icmp eq i32 %28, 3
br i1 %29, label %30, label %39
30: ; preds = %27
%31 = load i32, i32* %4
%32 = load i32, i32* %5
%33 = load i32*, i32** %2
%34 = call i32 @getushort(i32* %33)
%35 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %31, i32 %32, i32 %34)
%36 = load i32*, i32** %2
%37 = call i32 @getushort(i32* %36)
%38 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %37)
br label %42
39: ; preds = %27
%40 = load i32, i32* %3
%41 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %39, %30
br label %43
43: ; preds = %42, %21
br label %44
44: ; preds = %43, %14
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Attach at (%d,%d)\0A\00"
@.str.1 = [25 x i8] c"Attach at (%d,%d pt=%d)\0A\00"
@.str.2 = [31 x i8] c"Attach at (%d,%d XDeviceOff=%d\00"
@.str.3 = [17 x i8] c" YDeviceOff=%d)\0A\00"
@.str.4 = [30 x i8] c"Unknown attachment format %d\0A\00"
define void @ShowAttach(i32* %0) {
%2 = tail call i32 @getushort(i32* %0)
%3 = tail call i32 @getushort(i32* %0)
%4 = tail call i32 @getushort(i32* %0)
switch i32 %2, label %15 [
i32 1, label %5
i32 2, label %7
i32 3, label %10
]
5: ; preds = %1
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4)
br label %17
7: ; preds = %1
%8 = tail call i32 @getushort(i32* %0)
%9 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %3, i32 %4, i32 %8)
br label %17
10: ; preds = %1
%11 = tail call i32 @getushort(i32* %0)
%12 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %3, i32 %4, i32 %11)
%13 = tail call i32 @getushort(i32* %0)
%14 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %13)
br label %17
15: ; preds = %1
%16 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %2)
br label %17
17: ; preds = %7, %15, %10, %5
ret void
}