#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 sscanf(char const *, char *, char *, int *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
size_t strlen(char const *);
int match_c(const char *src, const char *o_fmt, char *c0) {
  char fmt[256];
  int r;
  int len = -1;
  strcpy(fmt, o_fmt);
  strcat(fmt, "%n");
  r = sscanf(src, fmt, c0, &len);
  return (r >= 1) && (len > 0) && ((size_t)len == strlen(src));
}


x86 assembly (clang, -O0):
<match_c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0xffffffff,-0x128(%rbp)
ff ff ff
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x120(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x128(%rbp),%rcx
call   1050 <sscanf@plt>
mov    %eax,-0x124(%rbp)
xor    %eax,%eax
cmpl   $0x1,-0x124(%rbp)
mov    %al,-0x129(%rbp)
jl     11fc <match_c+0xbc>
xor    %eax,%eax
cmpl   $0x0,-0x128(%rbp)
mov    %al,-0x129(%rbp)
jle    11fc <match_c+0xbc>
movslq -0x128(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x138(%rbp),%rax
cmp    %rcx,%rax
sete   %al
mov    %al,-0x129(%rbp)
mov    -0x129(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_c>:
push   %r15
push   %r14
push   %rbx
sub    $0x110,%rsp
mov    %rdx,%r15
mov    %rdi,%r14
movl   $0xffffffff,0xc(%rsp)
ff
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0xc(%rsp),%rcx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <sscanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jle    11ac <match_c+0x6c>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
jle    11ac <match_c+0x6c>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rbx,%rcx
sete   %al
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%n\00"
define i32 @match_c(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [256 x i8]
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 -1, i32* %9
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%11 = load i8*, i8** %5
%12 = call i32 @strcpy(i8* %10, i8* %11)
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%14 = call i32 @strcat(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%15 = load i8*, i8** %4
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%17 = load i8*, i8** %6
%18 = call i32 @sscanf(i8* %15, i8* %16, i8* %17, i32* %9)
store i32 %18, i32* %8
%19 = load i32, i32* %8
%20 = icmp sge i32 %19, 1
br i1 %20, label %21, label %30
21: ; preds = %3
%22 = load i32, i32* %9
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = load i8*, i8** %4
%28 = call i64 @strlen(i8* %27)
%29 = icmp eq i64 %26, %28
br label %30
30: ; preds = %24, %21, %3
%31 = phi i1 [ false, %21 ], [ false, %3 ], [ %29, %24 ]
%32 = zext i1 %31 to i32
ret i32 %32
}

LLVM IR (-O2):
@.str = [3 x i8] c"%n\00"
define i32 @match_c(i8* nocapture %0, i8* %1, i8* %2) {
%4 = alloca [256 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = bitcast i32* %5 to i8*
store i32 -1, i32* %5
%8 = call i32 @strcpy(i8* %6, i8* %1)
%9 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @sscanf(i8* %0, i8* %6, i8* %2, i32* %5)
%11 = icmp sgt i32 %10, 0
%12 = load i32, i32* %5
%13 = icmp sgt i32 %12, 0
%14 = select i1 %11, i1 %13, i1 false
br i1 %14, label %15, label %20
15: ; preds = %3
%16 = zext i32 %12 to i64
%17 = call i64 @strlen(i8* dereferenceable(1) %0)
%18 = icmp eq i64 %17, %16
%19 = zext i1 %18 to i32
br label %20
20: ; preds = %15, %3
%21 = phi i32 [ 0, %3 ], [ %19, %15 ]
ret i32 %21
}