int f0(const char *s) {
  int n = __builtin_snprintf(0, 0, "%.*s%08x", 1, s, 1);
  do {
    extern void failure_on_line_33(void);
    if (!(7 < n && n < 10))
      failure_on_line_33();
  } while (0);
  do {
    extern void keep_call_on_line_35(void);
    if (8 == n)
      keep_call_on_line_35();
  } while (0);
  do {
    extern void keep_call_on_line_36(void);
    if (9 == n)
      keep_call_on_line_36();
  } while (0);
  return n;
}


x86 assembly (clang, -O0):
<f0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%r8
xor    %eax,%eax
mov    %eax,%esi
lea    0xea5(%rip),%rdx
mov    $0x1,%r9d
mov    %rsi,%rdi
mov    %r9d,%ecx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %eax,-0xc(%rbp)
mov    $0x7,%eax
cmp    -0xc(%rbp),%eax
jge    1189 <f0+0x49>
cmpl   $0xa,-0xc(%rbp)
jl     118e <f0+0x4e>
call   1060 <failure_on_line_33@plt>
jmp    1193 <f0+0x53>
jmp    1198 <f0+0x58>
mov    $0x8,%eax
cmp    -0xc(%rbp),%eax
jne    11ab <f0+0x6b>
call   1050 <keep_call_on_line_35@plt>
jmp    11b0 <f0+0x70>
jmp    11b5 <f0+0x75>
mov    $0x9,%eax
cmp    -0xc(%rbp),%eax
jne    11c8 <f0+0x88>
call   1030 <keep_call_on_line_36@plt>
jmp    11cd <f0+0x8d>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f0>:
push   %rbx
mov    %rdi,%r8
lea    0xeb5(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x1,%ecx
mov    $0x1,%r9d
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %eax,%ebx
and    $0xfffffffe,%eax
cmp    $0x8,%eax
je     1170 <f0+0x30>
call   1060 <failure_on_line_33@plt>
cmp    $0x9,%ebx
je     1181 <f0+0x41>
cmp    $0x8,%ebx
jne    1186 <f0+0x46>
call   1050 <keep_call_on_line_35@plt>
jmp    1186 <f0+0x46>
call   1030 <keep_call_on_line_36@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%.*s%08x\00"
define i32 @f0(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 1, i8* %4, i32 1)
store i32 %5, i32* %3
br label %6
6: ; preds = %1
%7 = load i32, i32* %3
%8 = icmp slt i32 7, %7
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 10
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 8, %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 9, %22
br i1 %23, label %24, label %25
24: ; preds = %21
br label %25
25: ; preds = %24, %21
br label %26
26: ; preds = %25
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [9 x i8] c"%.*s%08x\00"
define i32 @f0(i8* %0) {
%2 = tail call i32 (i8*, i64, i8*, ...) @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 1, i8* %0, i32 1)
%3 = and i32 %2, -2
%4 = icmp eq i32 %3, 8
br i1 %4, label %6, label %5
5: ; preds = %1
tail call void @failure_on_line_33()
br label %6
6: ; preds = %5, %1
switch i32 %2, label %9 [
i32 8, label %7
i32 9, label %8
]
7: ; preds = %6
tail call void @keep_call_on_line_35()
br label %9
8: ; preds = %6
tail call void @keep_call_on_line_36()
br label %9
9: ; preds = %7, %6, %8
ret i32 %2
}