#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 */
double bar(char const *, int);
int /*<<< orphan*/ printf(char *, ...);
void foo(const char *pptr, int caplen) {
  int type;
  const char *tptr;
  if (caplen < 4) {
    (void)printf("foo");
    return;
  }
  while (tptr < pptr) {
    switch (type) {
    case 0x01:
      printf("");
    case 0x0b:
      printf("");
    case 0x0e:
      printf("");
    case 0x10:
      printf("%1.2fW", bar(tptr, caplen) / 1000.0);
    }
  }
  printf("foo");
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    114c <foo+0x2c>
lea    0xf08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11eb <foo+0xcb>
jmp    1151 <foo+0x31>
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11dd <foo+0xbd>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0xf,%eax
ja     11d8 <foo+0xb8>
mov    -0x20(%rbp),%rax
lea    0xe89(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <bar@plt>
movsd  0xe3a(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe7b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1151 <foo+0x31>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
lea    0xee9(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"foo\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [7 x i8] c"%1.2fW\00"
define void @foo(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %33
11: ; preds = %2
br label %12
12: ; preds = %30, %11
%13 = load i8*, i8** %6
%14 = load i8*, i8** %3
%15 = icmp ult i8* %13, %14
br i1 %15, label %16, label %31
16: ; preds = %12
%17 = load i32, i32* %5
switch i32 %17, label %30 [
i32 1, label %18
i32 11, label %20
i32 14, label %22
i32 16, label %24
]
18: ; preds = %16
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %16, %18
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %16, %20
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %16, %22
%25 = load i8*, i8** %6
%26 = load i32, i32* %4
%27 = call double @bar(i8* %25, i32 %26)
%28 = fdiv double %27, 1.000000e+03
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %28)
br label %30
30: ; preds = %24, %16
br label %12
31: ; preds = %12
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %33
33: ; preds = %31, %9
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"foo\00"
define void @foo(i8* nocapture readnone %0, i32 %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
ret void
}