int test_ho_var(int i) {
  int n = __builtin_snprintf(0, 0, "%#ho", i);
  do {
    extern void failure_on_line_53(void);
    if (!(0 < n && n < 8))
      failure_on_line_53();
  } while (0);
  do {
    extern void keep_call_on_line_55(void);
    if (1 == n)
      keep_call_on_line_55();
  } while (0);
  do {
    extern void keep_call_on_line_56(void);
    if (2 == n)
      keep_call_on_line_56();
  } while (0);
  do {
    extern void keep_call_on_line_57(void);
    if (3 == n)
      keep_call_on_line_57();
  } while (0);
  do {
    extern void keep_call_on_line_58(void);
    if (4 == n)
      keep_call_on_line_58();
  } while (0);
  do {
    extern void keep_call_on_line_59(void);
    if (5 == n)
      keep_call_on_line_59();
  } while (0);
  do {
    extern void keep_call_on_line_60(void);
    if (6 == n)
      keep_call_on_line_60();
  } while (0);
  do {
    extern void keep_call_on_line_61(void);
    if (7 == n)
      keep_call_on_line_61();
  } while (0);
  return n;
}


x86 assembly (clang, -O0):
<test_ho_var>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
xor    %eax,%eax
mov    %eax,%esi
lea    0xe57(%rip),%rdx
mov    %rsi,%rdi
mov    $0x0,%al
call   1070 <snprintf@plt>
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
jge    11cb <test_ho_var+0x3b>
cmpl   $0x8,-0x8(%rbp)
jl     11d0 <test_ho_var+0x40>
call   1080 <failure_on_line_53@plt>
jmp    11d5 <test_ho_var+0x45>
jmp    11da <test_ho_var+0x4a>
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
jne    11ed <test_ho_var+0x5d>
call   1040 <keep_call_on_line_55@plt>
jmp    11f2 <test_ho_var+0x62>
jmp    11f7 <test_ho_var+0x67>
mov    $0x2,%eax
cmp    -0x8(%rbp),%eax
jne    120a <test_ho_var+0x7a>
call   10a0 <keep_call_on_line_56@plt>
jmp    120f <test_ho_var+0x7f>
jmp    1214 <test_ho_var+0x84>
mov    $0x3,%eax
cmp    -0x8(%rbp),%eax
jne    1227 <test_ho_var+0x97>
call   1050 <keep_call_on_line_57@plt>
jmp    122c <test_ho_var+0x9c>
jmp    1231 <test_ho_var+0xa1>
mov    $0x4,%eax
cmp    -0x8(%rbp),%eax
jne    1244 <test_ho_var+0xb4>
call   10b0 <keep_call_on_line_58@plt>
jmp    1249 <test_ho_var+0xb9>
jmp    124e <test_ho_var+0xbe>
mov    $0x5,%eax
cmp    -0x8(%rbp),%eax
jne    1261 <test_ho_var+0xd1>
call   1060 <keep_call_on_line_59@plt>
jmp    1266 <test_ho_var+0xd6>
jmp    126b <test_ho_var+0xdb>
mov    $0x6,%eax
cmp    -0x8(%rbp),%eax
jne    127e <test_ho_var+0xee>
call   1030 <keep_call_on_line_60@plt>
jmp    1283 <test_ho_var+0xf3>
jmp    1288 <test_ho_var+0xf8>
mov    $0x7,%eax
cmp    -0x8(%rbp),%eax
jne    129b <test_ho_var+0x10b>
call   1090 <keep_call_on_line_61@plt>
jmp    12a0 <test_ho_var+0x110>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_ho_var>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ecx
lea    0xe7f(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1070 <snprintf@plt>
mov    %eax,%r14d
lea    -0x1(%r14),%ebx
cmp    $0x7,%ebx
jb     11b9 <test_ho_var+0x29>
call   1080 <failure_on_line_53@plt>
cmp    $0x6,%ebx
ja     11fd <test_ho_var+0x6d>
lea    0xe3b(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
call   1040 <keep_call_on_line_55@plt>
jmp    11fd <test_ho_var+0x6d>
call   10a0 <keep_call_on_line_56@plt>
jmp    11fd <test_ho_var+0x6d>
call   1050 <keep_call_on_line_57@plt>
jmp    11fd <test_ho_var+0x6d>
call   10b0 <keep_call_on_line_58@plt>
jmp    11fd <test_ho_var+0x6d>
call   1060 <keep_call_on_line_59@plt>
jmp    11fd <test_ho_var+0x6d>
call   1030 <keep_call_on_line_60@plt>
jmp    11fd <test_ho_var+0x6d>
call   1090 <keep_call_on_line_61@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%#ho\00"
define i32 @test_ho_var(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 %5, i32* %3
br label %6
6: ; preds = %1
%7 = load i32, i32* %3
%8 = icmp slt i32 0, %7
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 8
br i1 %11, label %13, label %12
12: ; preds = %9, %6
br label %13
13: ; preds = %12, %9
br label %14
14: ; preds = %13
br label %15
15: ; preds = %14
%16 = load i32, i32* %3
%17 = icmp eq i32 1, %16
br i1 %17, label %18, label %19
18: ; preds = %15
br label %19
19: ; preds = %18, %15
br label %20
20: ; preds = %19
br label %21
21: ; preds = %20
%22 = load i32, i32* %3
%23 = icmp eq i32 2, %22
br i1 %23, label %24, label %25
24: ; preds = %21
br label %25
25: ; preds = %24, %21
br label %26
26: ; preds = %25
br label %27
27: ; preds = %26
%28 = load i32, i32* %3
%29 = icmp eq i32 3, %28
br i1 %29, label %30, label %31
30: ; preds = %27
br label %31
31: ; preds = %30, %27
br label %32
32: ; preds = %31
br label %33
33: ; preds = %32
%34 = load i32, i32* %3
%35 = icmp eq i32 4, %34
br i1 %35, label %36, label %37
36: ; preds = %33
br label %37
37: ; preds = %36, %33
br label %38
38: ; preds = %37
br label %39
39: ; preds = %38
%40 = load i32, i32* %3
%41 = icmp eq i32 5, %40
br i1 %41, label %42, label %43
42: ; preds = %39
br label %43
43: ; preds = %42, %39
br label %44
44: ; preds = %43
br label %45
45: ; preds = %44
%46 = load i32, i32* %3
%47 = icmp eq i32 6, %46
br i1 %47, label %48, label %49
48: ; preds = %45
br label %49
49: ; preds = %48, %45
br label %50
50: ; preds = %49
br label %51
51: ; preds = %50
%52 = load i32, i32* %3
%53 = icmp eq i32 7, %52
br i1 %53, label %54, label %55
54: ; preds = %51
br label %55
55: ; preds = %54, %51
br label %56
56: ; preds = %55
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
@.str = [5 x i8] c"%#ho\00"
define i32 @test_ho_var(i32 %0) {
%2 = tail call i32 (i8*, i64, i8*, ...) @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %0)
%3 = add i32 %2, -1
%4 = icmp ult i32 %3, 7
br i1 %4, label %6, label %5
5: ; preds = %1
tail call void @failure_on_line_53()
br label %6
6: ; preds = %5, %1
switch i32 %2, label %14 [
i32 1, label %7
i32 2, label %8
i32 3, label %9
i32 4, label %10
i32 5, label %11
i32 6, label %12
i32 7, label %13
]
7: ; preds = %6
tail call void @keep_call_on_line_55()
br label %14
8: ; preds = %6
tail call void @keep_call_on_line_56()
br label %14
9: ; preds = %6
tail call void @keep_call_on_line_57()
br label %14
10: ; preds = %6
tail call void @keep_call_on_line_58()
br label %14
11: ; preds = %6
tail call void @keep_call_on_line_59()
br label %14
12: ; preds = %6
tail call void @keep_call_on_line_60()
br label %14
13: ; preds = %6
tail call void @keep_call_on_line_61()
br label %14
14: ; preds = %12, %11, %10, %9, %8, %7, %6, %13
ret i32 %2
}