int test_x_var(int i) {
  int n = __builtin_snprintf(0, 0, "%#x", i);
  do {
    extern void failure_on_line_142(void);
    if (!(0 < n && n < 11))
      failure_on_line_142();
  } while (0);
  do {
    extern void keep_call_on_line_144(void);
    if (1 == n)
      keep_call_on_line_144();
  } while (0);
  do {
    extern void keep_call_on_line_145(void);
    if (2 == n)
      keep_call_on_line_145();
  } while (0);
  do {
    extern void keep_call_on_line_146(void);
    if (3 == n)
      keep_call_on_line_146();
  } while (0);
  do {
    extern void keep_call_on_line_147(void);
    if (4 == n)
      keep_call_on_line_147();
  } while (0);
  do {
    extern void keep_call_on_line_148(void);
    if (5 == n)
      keep_call_on_line_148();
  } while (0);
  do {
    extern void keep_call_on_line_149(void);
    if (6 == n)
      keep_call_on_line_149();
  } while (0);
  do {
    extern void keep_call_on_line_150(void);
    if (7 == n)
      keep_call_on_line_150();
  } while (0);
  do {
    extern void keep_call_on_line_151(void);
    if (8 == n)
      keep_call_on_line_151();
  } while (0);
  do {
    extern void keep_call_on_line_152(void);
    if (9 == n)
      keep_call_on_line_152();
  } while (0);
  do {
    extern void keep_call_on_line_153(void);
    if (10 == n)
      keep_call_on_line_153();
  } while (0);
  return n;
}


x86 assembly (clang, -O0):
<test_x_var>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
xor    %eax,%eax
mov    %eax,%esi
lea    0xe27(%rip),%rdx
mov    %rsi,%rdi
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
jge    11fb <test_x_var+0x3b>
cmpl   $0xb,-0x8(%rbp)
jl     1200 <test_x_var+0x40>
call   10a0 <failure_on_line_142@plt>
jmp    1205 <test_x_var+0x45>
jmp    120a <test_x_var+0x4a>
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
jne    121d <test_x_var+0x5d>
call   10e0 <keep_call_on_line_144@plt>
jmp    1222 <test_x_var+0x62>
jmp    1227 <test_x_var+0x67>
mov    $0x2,%eax
cmp    -0x8(%rbp),%eax
jne    123a <test_x_var+0x7a>
call   1090 <keep_call_on_line_145@plt>
jmp    123f <test_x_var+0x7f>
jmp    1244 <test_x_var+0x84>
mov    $0x3,%eax
cmp    -0x8(%rbp),%eax
jne    1257 <test_x_var+0x97>
call   10d0 <keep_call_on_line_146@plt>
jmp    125c <test_x_var+0x9c>
jmp    1261 <test_x_var+0xa1>
mov    $0x4,%eax
cmp    -0x8(%rbp),%eax
jne    1274 <test_x_var+0xb4>
call   1070 <keep_call_on_line_147@plt>
jmp    1279 <test_x_var+0xb9>
jmp    127e <test_x_var+0xbe>
mov    $0x5,%eax
cmp    -0x8(%rbp),%eax
jne    1291 <test_x_var+0xd1>
call   10c0 <keep_call_on_line_148@plt>
jmp    1296 <test_x_var+0xd6>
jmp    129b <test_x_var+0xdb>
mov    $0x6,%eax
cmp    -0x8(%rbp),%eax
jne    12ae <test_x_var+0xee>
call   1060 <keep_call_on_line_149@plt>
jmp    12b3 <test_x_var+0xf3>
jmp    12b8 <test_x_var+0xf8>
mov    $0x7,%eax
cmp    -0x8(%rbp),%eax
jne    12cb <test_x_var+0x10b>
call   10b0 <keep_call_on_line_150@plt>
jmp    12d0 <test_x_var+0x110>
jmp    12d5 <test_x_var+0x115>
mov    $0x8,%eax
cmp    -0x8(%rbp),%eax
jne    12e8 <test_x_var+0x128>
call   1030 <keep_call_on_line_151@plt>
jmp    12ed <test_x_var+0x12d>
jmp    12f2 <test_x_var+0x132>
mov    $0x9,%eax
cmp    -0x8(%rbp),%eax
jne    1305 <test_x_var+0x145>
call   1080 <keep_call_on_line_152@plt>
jmp    130a <test_x_var+0x14a>
jmp    130f <test_x_var+0x14f>
mov    $0xa,%eax
cmp    -0x8(%rbp),%eax
jne    1322 <test_x_var+0x162>
call   1040 <keep_call_on_line_153@plt>
jmp    1327 <test_x_var+0x167>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_x_var>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ecx
lea    0xe5b(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %eax,%r14d
lea    -0x1(%r14),%ebx
cmp    $0xa,%ebx
jb     11e9 <test_x_var+0x29>
call   10a0 <failure_on_line_142@plt>
cmp    $0x9,%ebx
ja     1242 <test_x_var+0x82>
lea    0xe0b(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
call   10e0 <keep_call_on_line_144@plt>
jmp    1242 <test_x_var+0x82>
call   1090 <keep_call_on_line_145@plt>
jmp    1242 <test_x_var+0x82>
call   10d0 <keep_call_on_line_146@plt>
jmp    1242 <test_x_var+0x82>
call   1070 <keep_call_on_line_147@plt>
jmp    1242 <test_x_var+0x82>
call   10c0 <keep_call_on_line_148@plt>
jmp    1242 <test_x_var+0x82>
call   1060 <keep_call_on_line_149@plt>
jmp    1242 <test_x_var+0x82>
call   10b0 <keep_call_on_line_150@plt>
jmp    1242 <test_x_var+0x82>
call   1030 <keep_call_on_line_151@plt>
jmp    1242 <test_x_var+0x82>
call   1040 <keep_call_on_line_153@plt>
jmp    1242 <test_x_var+0x82>
call   1080 <keep_call_on_line_152@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%#x\00"
define i32 @test_x_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 ([4 x i8], [4 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, 11
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
br label %57
57: ; preds = %56
%58 = load i32, i32* %3
%59 = icmp eq i32 8, %58
br i1 %59, label %60, label %61
60: ; preds = %57
br label %61
61: ; preds = %60, %57
br label %62
62: ; preds = %61
br label %63
63: ; preds = %62
%64 = load i32, i32* %3
%65 = icmp eq i32 9, %64
br i1 %65, label %66, label %67
66: ; preds = %63
br label %67
67: ; preds = %66, %63
br label %68
68: ; preds = %67
br label %69
69: ; preds = %68
%70 = load i32, i32* %3
%71 = icmp eq i32 10, %70
br i1 %71, label %72, label %73
72: ; preds = %69
br label %73
73: ; preds = %72, %69
br label %74
74: ; preds = %73
%75 = load i32, i32* %3
ret i32 %75
}

LLVM IR (-O2):
@.str = [4 x i8] c"%#x\00"
define i32 @test_x_var(i32 %0) {
%2 = tail call i32 (i8*, i64, i8*, ...) @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %0)
%3 = add i32 %2, -1
%4 = icmp ult i32 %3, 10
br i1 %4, label %6, label %5
5: ; preds = %1
tail call void @failure_on_line_142()
br label %6
6: ; preds = %5, %1
switch i32 %2, label %17 [
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
i32 8, label %14
i32 9, label %15
i32 10, label %16
]
7: ; preds = %6
tail call void @keep_call_on_line_144()
br label %17
8: ; preds = %6
tail call void @keep_call_on_line_145()
br label %17
9: ; preds = %6
tail call void @keep_call_on_line_146()
br label %17
10: ; preds = %6
tail call void @keep_call_on_line_147()
br label %17
11: ; preds = %6
tail call void @keep_call_on_line_148()
br label %17
12: ; preds = %6
tail call void @keep_call_on_line_149()
br label %17
13: ; preds = %6
tail call void @keep_call_on_line_150()
br label %17
14: ; preds = %6
tail call void @keep_call_on_line_151()
br label %17
15: ; preds = %6
tail call void @keep_call_on_line_152()
br label %17
16: ; preds = %6
tail call void @keep_call_on_line_153()
br label %17
17: ; preds = %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %16
ret i32 %2
}