#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 get1();
int get2();
int /*<<< orphan*/ printf(char *, int, ...);
void get_sos(int kind) {
  int i, length, ncomponents, id, dcac, ahal;
  length = get2();
  ncomponents = get1();
  printf("SOS:\t%d components\n", ncomponents);
  for (i = 0; i < ncomponents; i++) {
    id = get1();
    dcac = get1();
    printf("\tcomponent %d: %d DC, %d AC\n", id, dcac >> 4, dcac & 0xf);
  }
  printf("\tstart spectral %d\n", get1());
  printf("\tend spectral %d\n", get1());
  ahal = get1();
  printf("\tah = %d, al = %d\n", ahal >> 4, ahal & 0xf);
}


x86 assembly (clang, -O0):
<get_sos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1030 <get2@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1050 <get1@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11b2 <get_sos+0x82>
mov    $0x0,%al
call   1050 <get1@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1050 <get1@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
sar    $0x4,%edx
mov    -0x18(%rbp),%ecx
and    $0xf,%ecx
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1167 <get_sos+0x37>
mov    $0x0,%al
call   1050 <get1@plt>
mov    %eax,%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <get1@plt>
mov    %eax,%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <get1@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
sar    $0x4,%esi
mov    -0x1c(%rbp),%edx
and    $0xf,%edx
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_sos>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <get2@plt>
xor    %eax,%eax
call   1050 <get1@plt>
mov    %eax,%ebx
lea    0xeb5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
jle    118b <get_sos+0x5b>
lea    0xeb5(%rip),%r14
nop
xor    %eax,%eax
call   1050 <get1@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <get1@plt>
mov    %eax,%edx
sar    $0x4,%edx
and    $0xf,%eax
mov    %r14,%rdi
mov    %ebp,%esi
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebx
jne    1160 <get_sos+0x30>
xor    %eax,%eax
call   1050 <get1@plt>
lea    0xe98(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <get1@plt>
lea    0xe95(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <get1@plt>
mov    %eax,%esi
sar    $0x4,%esi
and    $0xf,%eax
lea    0xe88(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"SOS:\09%d components\0A\00"
@.str.1 = [29 x i8] c"\09component %d: %d DC, %d AC\0A\00"
@.str.2 = [20 x i8] c"\09start spectral %d\0A\00"
@.str.3 = [18 x i8] c"\09end spectral %d\0A\00"
@.str.4 = [19 x i8] c"\09ah = %d, al = %d\0A\00"
define void @get_sos(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %2
%9 = call i32 (...) @get2()
store i32 %9, i32* %4
%10 = call i32 (...) @get1()
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 0, i32* %3
br label %13
13: ; preds = %26, %1
%14 = load i32, i32* %3
%15 = load i32, i32* %5
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %29
17: ; preds = %13
%18 = call i32 (...) @get1()
store i32 %18, i32* %6
%19 = call i32 (...) @get1()
store i32 %19, i32* %7
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = ashr i32 %21, 4
%23 = load i32, i32* %7
%24 = and i32 %23, 15
%25 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %22, i32 %24)
br label %26
26: ; preds = %17
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %13
29: ; preds = %13
%30 = call i32 (...) @get1()
%31 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = call i32 (...) @get1()
%33 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = call i32 (...) @get1()
store i32 %34, i32* %8
%35 = load i32, i32* %8
%36 = ashr i32 %35, 4
%37 = load i32, i32* %8
%38 = and i32 %37, 15
%39 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %36, i32 %38)
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"SOS:\09%d components\0A\00"
@.str.1 = [29 x i8] c"\09component %d: %d DC, %d AC\0A\00"
@.str.2 = [20 x i8] c"\09start spectral %d\0A\00"
@.str.3 = [18 x i8] c"\09end spectral %d\0A\00"
@.str.4 = [19 x i8] c"\09ah = %d, al = %d\0A\00"
define void @get_sos(i32 %0) {
%2 = tail call i32 (...) @get2()
%3 = tail call i32 (...) @get1()
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %15
6: ; preds = %1, %6
%7 = phi i32 [ %13, %6 ], [ 0, %1 ]
%8 = tail call i32 (...) @get1()
%9 = tail call i32 (...) @get1()
%10 = ashr i32 %9, 4
%11 = and i32 %9, 15
%12 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %10, i32 %11)
%13 = add nuw nsw i32 %7, 1
%14 = icmp eq i32 %13, %3
br i1 %14, label %15, label %6
15: ; preds = %6, %1
%16 = tail call i32 (...) @get1()
%17 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = tail call i32 (...) @get1()
%19 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = tail call i32 (...) @get1()
%21 = ashr i32 %20, 4
%22 = and i32 %20, 15
%23 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %21, i32 %22)
ret void
}