#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*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
scalar_t__ strmatch(char const *, char const *, size_t *);
int main(void) {
  const char *string = "she sells sea shells ";
  const char *pattern = "sea";
  size_t index;
  if (strmatch(string, pattern, &index)) {
    printf("%d文字目に一致しました。\n", (int)(index + 1));
  } else {
    puts("一致しませんでした。");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xec5(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1040 <strmatch@plt>
cmp    $0x0,%rax
je     118b <main+0x5b>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %eax,%esi
lea    0xe99(%rip),%rdi
call   1050 <printf@plt>
jmp    1197 <main+0x67>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
lea    0xed7(%rip),%rsi
mov    %rsp,%rdx
call   1040 <strmatch@plt>
test   %rax,%rax
je     1160 <main+0x30>
mov    (%rsp),%esi
add    $0x1,%esi
lea    0xec1(%rip),%rdi
call   1050 <printf@plt>
jmp    116c <main+0x3c>
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"she sells sea shells \00"
@.str.1 = [4 x i8] c"sea\00"
@.str.2 = [37 x i8] c"%d\E6\96\87\E5\AD\97\E7\9B\AE\E3\81\AB\E4\B8\80\E8\87\B4\E3\81\97\E3\81\BE\E3\81\97\E3\81\9F\E3\80\82\0A\00"
@.str.3 = [31 x i8] c"\E4\B8\80\E8\87\B4\E3\81\97\E3\81\BE\E3\81\9B\E3\82\93\E3\81\A7\E3\81\97\E3\81\9F\E3\80\82\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
store i32 0, i32* %1
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %3
%5 = load i8*, i8** %2
%6 = load i8*, i8** %3
%7 = call i64 @strmatch(i8* %5, i8* %6, i64* %4)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %0
%10 = load i64, i64* %4
%11 = add i64 %10, 1
%12 = trunc i64 %11 to i32
%13 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %12)
br label %16
14: ; preds = %0
%15 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %14, %9
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"she sells sea shells \00"
@.str.1 = [4 x i8] c"sea\00"
@.str.2 = [37 x i8] c"%d\E6\96\87\E5\AD\97\E7\9B\AE\E3\81\AB\E4\B8\80\E8\87\B4\E3\81\97\E3\81\BE\E3\81\97\E3\81\9F\E3\80\82\0A\00"
@.str.3 = [31 x i8] c"\E4\B8\80\E8\87\B4\E3\81\97\E3\81\BE\E3\81\9B\E3\82\93\E3\81\A7\E3\81\97\E3\81\9F\E3\80\82\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = call i64 @strmatch(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %0
%6 = load i64, i64* %1
%7 = trunc i64 %6 to i32
%8 = add i32 %7, 1
%9 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %8)
br label %12
10: ; preds = %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %12
12: ; preds = %10, %5
ret i32 0
}