void test_hhx_cst(void) {
  do {
    extern void failure_on_line_90(void);
    if (!(1 == __builtin_snprintf(0, 0, "%#.1hhx", 0)))
      failure_on_line_90();
  } while (0);
  do {
    extern void failure_on_line_91(void);
    if (!(2 == __builtin_snprintf(0, 0, "%#.2hhx", 0)))
      failure_on_line_91();
  } while (0);
  do {
    extern void failure_on_line_93(void);
    if (!(3 == __builtin_snprintf(0, 0, "%#.1hhx", 1)))
      failure_on_line_93();
  } while (0);
  do {
    extern void failure_on_line_94(void);
    if (!(4 == __builtin_snprintf(0, 0, "%#.2hhx", 1)))
      failure_on_line_94();
  } while (0);
  do {
    extern void failure_on_line_95(void);
    if (!(5 == __builtin_snprintf(0, 0, "%#.3hhx", 1)))
      failure_on_line_95();
  } while (0);
}


x86 assembly (clang, -O0):
<test_hhx_cst>:
push   %rbp
mov    %rsp,%rbp
jmp    1169 <test_hhx_cst+0x9>
xor    %eax,%eax
mov    %eax,%esi
lea    0xe8c(%rip),%rdx
xor    %ecx,%ecx
mov    %rsi,%rdi
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     1194 <test_hhx_cst+0x34>
call   1050 <failure_on_line_90@plt>
jmp    1199 <test_hhx_cst+0x39>
jmp    119e <test_hhx_cst+0x3e>
xor    %eax,%eax
mov    %eax,%esi
lea    0xe5f(%rip),%rdx
xor    %ecx,%ecx
mov    %rsi,%rdi
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    %ecx,%eax
je     11c9 <test_hhx_cst+0x69>
call   1080 <failure_on_line_91@plt>
jmp    11ce <test_hhx_cst+0x6e>
jmp    11d3 <test_hhx_cst+0x73>
xor    %eax,%eax
mov    %eax,%esi
lea    0xe22(%rip),%rdx
mov    $0x1,%ecx
mov    %rsi,%rdi
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,%ecx
mov    $0x3,%eax
cmp    %ecx,%eax
je     1201 <test_hhx_cst+0xa1>
call   1060 <failure_on_line_93@plt>
jmp    1206 <test_hhx_cst+0xa6>
jmp    120b <test_hhx_cst+0xab>
xor    %eax,%eax
mov    %eax,%esi
lea    0xdf2(%rip),%rdx
mov    $0x1,%ecx
mov    %rsi,%rdi
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,%ecx
mov    $0x4,%eax
cmp    %ecx,%eax
je     1239 <test_hhx_cst+0xd9>
call   1040 <failure_on_line_94@plt>
jmp    123e <test_hhx_cst+0xde>
jmp    1243 <test_hhx_cst+0xe3>
xor    %eax,%eax
mov    %eax,%esi
lea    0xdc2(%rip),%rdx
mov    $0x1,%ecx
mov    %rsi,%rdi
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,%ecx
mov    $0x5,%eax
cmp    %ecx,%eax
je     1271 <test_hhx_cst+0x111>
call   1070 <failure_on_line_95@plt>
jmp    1276 <test_hhx_cst+0x116>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_hhx_cst>:
push   %rax
lea    0xe98(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
xor    %ecx,%ecx
xor    %eax,%eax
call   1030 <snprintf@plt>
cmp    $0x1,%eax
je     117f <test_hhx_cst+0x1f>
call   1050 <failure_on_line_90@plt>
lea    0xe82(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
xor    %ecx,%ecx
xor    %eax,%eax
call   1030 <snprintf@plt>
cmp    $0x2,%eax
je     119d <test_hhx_cst+0x3d>
call   1080 <failure_on_line_91@plt>
lea    0xe5c(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x1,%ecx
xor    %eax,%eax
call   1030 <snprintf@plt>
cmp    $0x3,%eax
je     11be <test_hhx_cst+0x5e>
call   1060 <failure_on_line_93@plt>
lea    0xe43(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x1,%ecx
xor    %eax,%eax
call   1030 <snprintf@plt>
cmp    $0x4,%eax
je     11df <test_hhx_cst+0x7f>
call   1040 <failure_on_line_94@plt>
lea    0xe2a(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x1,%ecx
xor    %eax,%eax
call   1030 <snprintf@plt>
cmp    $0x5,%eax
jne    11fd <test_hhx_cst+0x9d>
pop    %rax
ret
pop    %rax
jmp    1070 <failure_on_line_95@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%#.1hhx\00"
@.str.1 = [8 x i8] c"%#.2hhx\00"
@.str.2 = [8 x i8] c"%#.3hhx\00"
define void @test_hhx_cst() {
br label %1
1: ; preds = %0
%2 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 0)
%3 = icmp eq i32 1, %2
br i1 %3, label %5, label %4
4: ; preds = %1
br label %5
5: ; preds = %4, %1
br label %6
6: ; preds = %5
br label %7
7: ; preds = %6
%8 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 0)
%9 = icmp eq i32 2, %8
br i1 %9, label %11, label %10
10: ; preds = %7
br label %11
11: ; preds = %10, %7
br label %12
12: ; preds = %11
br label %13
13: ; preds = %12
%14 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 1)
%15 = icmp eq i32 3, %14
br i1 %15, label %17, label %16
16: ; preds = %13
br label %17
17: ; preds = %16, %13
br label %18
18: ; preds = %17
br label %19
19: ; preds = %18
%20 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 1)
%21 = icmp eq i32 4, %20
br i1 %21, label %23, label %22
22: ; preds = %19
br label %23
23: ; preds = %22, %19
br label %24
24: ; preds = %23
br label %25
25: ; preds = %24
%26 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 1)
%27 = icmp eq i32 5, %26
br i1 %27, label %29, label %28
28: ; preds = %25
br label %29
29: ; preds = %28, %25
br label %30
30: ; preds = %29
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%#.1hhx\00"
@.str.1 = [8 x i8] c"%#.2hhx\00"
@.str.2 = [8 x i8] c"%#.3hhx\00"
define void @test_hhx_cst() {
%1 = tail call i32 (i8*, i64, i8*, ...) @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 0)
%2 = icmp eq i32 %1, 1
br i1 %2, label %4, label %3
3: ; preds = %0
tail call void @failure_on_line_90()
br label %4
4: ; preds = %3, %0
%5 = tail call i32 (i8*, i64, i8*, ...) @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 0)
%6 = icmp eq i32 %5, 2
br i1 %6, label %8, label %7
7: ; preds = %4
tail call void @failure_on_line_91()
br label %8
8: ; preds = %7, %4
%9 = tail call i32 (i8*, i64, i8*, ...) @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 1)
%10 = icmp eq i32 %9, 3
br i1 %10, label %12, label %11
11: ; preds = %8
tail call void @failure_on_line_93()
br label %12
12: ; preds = %11, %8
%13 = tail call i32 (i8*, i64, i8*, ...) @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 1)
%14 = icmp eq i32 %13, 4
br i1 %14, label %16, label %15
15: ; preds = %12
tail call void @failure_on_line_94()
br label %16
16: ; preds = %15, %12
%17 = tail call i32 (i8*, i64, i8*, ...) @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 1)
%18 = icmp eq i32 %17, 5
br i1 %18, label %20, label %19
19: ; preds = %16
tail call void @failure_on_line_95()
br label %20
20: ; preds = %16, %19
ret void
}