#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 */
int /*<<< orphan*/ abort();
int g();
int /*<<< orphan*/ sprintf(char *, char *);
f() {
  char s[] = "abcedfg012345";
  char *sp = s + 12;
  switch (g()) {
  case '\n':
    break;
  }
  while (*--sp == '0')
    ;
  sprintf(sp + 1, "X");
  if (s[12] != 'X')
    abort();
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movabs $0x35343332313067,%rax
mov    %rax,-0x12(%rbp)
movabs $0x3067666465636261,%rax
66 67 30
mov    %rax,-0x18(%rbp)
lea    -0xc(%rbp),%rax
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
call   1040 <g@plt>
sub    $0xa,%eax
jne    1176 <f+0x46>
jmp    1171 <f+0x41>
jmp    1176 <f+0x46>
jmp    117b <f+0x4b>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x20(%rbp)
movsbl -0x1(%rax),%eax
cmp    $0x30,%eax
jne    119c <f+0x6c>
jmp    117b <f+0x4b>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
lea    0xe63(%rip),%rsi
call   1050 <sprintf@plt>
movsbl -0xc(%rbp),%eax
cmp    $0x58,%eax
je     11c4 <f+0x94>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
sub    $0x18,%rsp
movabs $0x35343332313067,%rax
mov    %rax,0xe(%rsp)
movabs $0x3067666465636261,%rax
66 67 30
mov    %rax,0x8(%rsp)
xor    %eax,%eax
call   1040 <g@plt>
lea    0x15(%rsp),%rax
xchg   %ax,%ax
cmpb   $0x30,-0x2(%rax)
lea    -0x1(%rax),%rax
je     1150 <f+0x30>
movw   $0x58,(%rax)
cmpb   $0x58,0x14(%rsp)
jne    116b <f+0x4b>
add    $0x18,%rsp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@__const.f.s = [14 x i8] c"abcedfg012345\00"
@.str = [2 x i8] c"X\00"
define i32 @f() {
%1 = alloca i32
%2 = alloca [14 x i8]
%3 = alloca i8*
%4 = bitcast [14 x i8]* %2 to i8*
%5 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds i8, i8* %5, i64 12
store i8* %6, i8** %3
%7 = call i32 (...) @g()
switch i32 %7, label %9 [
i32 10, label %8
]
8: ; preds = %0
br label %9
9: ; preds = %0, %8
br label %10
10: ; preds = %16, %9
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i32 -1
store i8* %12, i8** %3
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 48
br i1 %15, label %16, label %17
16: ; preds = %10
br label %10
17: ; preds = %10
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%21 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 12
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 88
br i1 %24, label %25, label %27
25: ; preds = %17
%26 = call i32 (...) @abort()
unreachable
27: ; preds = %17
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@__const.f.s = [14 x i8] c"abcedfg012345\00"
define i32 @f() {
%1 = alloca [14 x i8]
%2 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 12
%4 = tail call i32 (...) @g()
br label %5
5: ; preds = %5, %0
%6 = phi i8* [ %3, %0 ], [ %7, %5 ]
%7 = getelementptr inbounds i8, i8* %6, i64 -1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 48
br i1 %9, label %5, label %10
10: ; preds = %5
%11 = bitcast i8* %6 to i16*
store i16 88, i16* %11
%12 = load i8, i8* %3
%13 = icmp eq i8 %12, 88
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = tail call i32 (...) @abort()
unreachable
16: ; preds = %10
ret i32 undef
}