#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *, char *, int *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  FILE *fp;
  char hinmei[31];
  int kosu, num;
  fp = fopen("syohin.txt", "r");
  if (fp == NULL) {
    printf("ファイルがオープンできません。\n");
    exit(1);
  }
  printf("***** 商品ファイル *****\n");
  while (fscanf(fp, "%4d%31s%10d", &num, hinmei, &kosu) != EOF) {
    fseek(fp, num * 47, SEEK_SET);
    printf("%d %s %d\n", num, hinmei, kosu);
  }
  fclose(fp);
  printf("\n出力したいレコード番号を入力: ");
  scanf("%d", &num);
  fp = fopen("syohin.txt", "r");
  if (fp == NULL) {
    printf("ファイルがオープンできません。\n");
    exit(1);
  }
  fseek(fp, (num - 1) * 47, SEEK_SET);
  if (fscanf(fp, "%4d%31s%10d\n", &num, hinmei, &kosu) != EOF) {
    printf("%s\n", hinmei);
  } else {
    printf("該当するレコードが見つかりませんでした。\n");
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
lea    0xe7e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b9 <main+0x49>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rcx
lea    0xe86(%rip),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x34(%rbp),%r8
call   1050 <fscanf@plt>
mov    0x2dfe(%rip),%rcx
cmp    (%rcx),%rax
je     1226 <main+0xb6>
mov    -0x10(%rbp),%rdi
imul   $0x2f,-0x38(%rbp),%esi
mov    0x2dd6(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x38(%rbp),%esi
lea    -0x30(%rbp),%rdx
mov    -0x34(%rbp),%ecx
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c7 <main+0x57>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe5c(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xdac(%rip),%rdi
lea    0xdb0(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1287 <main+0x117>
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%eax
sub    $0x1,%eax
imul   $0x2f,%eax,%esi
mov    0x2d3d(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rcx
lea    0xdf2(%rip),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x34(%rbp),%r8
call   1050 <fscanf@plt>
mov    0x2d23(%rip),%rcx
cmp    (%rcx),%rax
je     12e5 <main+0x175>
lea    -0x30(%rbp),%rsi
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12f3 <main+0x183>
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xe6b(%rip),%rdi
lea    0xe6f(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12f2 <main+0x172>
mov    %rax,%rbx
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4d(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %rbx,%rdi
call   1060 <fscanf@plt>
mov    0x2e0a(%rip),%r14
cmp    (%r14),%rax
je     1248 <main+0xc8>
lea    0x10(%rsp),%r15
lea    0xe1e(%rip),%r12
lea    0x8(%rsp),%r13
lea    0xc(%rsp),%rbp
nopl   0x0(%rax)
imul   $0x2f,0x8(%rsp),%esi
mov    0x2dcc(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
call   1070 <fseek@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%ecx
lea    0xdf4(%rip),%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %r15,%rcx
mov    %rbp,%r8
call   1060 <fscanf@plt>
cmp    (%r14),%rax
jne    1200 <main+0x80>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xdcc(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdec(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1080 <scanf@plt>
lea    0xd8a(%rip),%rdi
lea    0xd8e(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12f2 <main+0x172>
mov    %rax,%rbx
imul   $0x2f,0x8(%rsp),%esi
add    $0xffffffd1,%esi
mov    0x2d3f(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
call   1070 <fseek@plt>
lea    0xdaa(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %rbx,%rdi
call   1060 <fscanf@plt>
cmp    (%r14),%rax
jne    12cf <main+0x14f>
lea    0xdb3(%rip),%rdi
jmp    12d4 <main+0x154>
lea    0x10(%rsp),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdc4(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"syohin.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [47 x i8] c"\E3\83\95\E3\82\A1\E3\82\A4\E3\83\AB\E3\81\8C\E3\82\AA\E3\83\BC\E3\83\97\E3\83\B3\E3\81\A7\E3\81\8D\E3\81\BE\E3\81\9B\E3\82\93\E3\80\82\0A\00"
@.str.3 = [32 x i8] c"***** \E5\95\86\E5\93\81\E3\83\95\E3\82\A1\E3\82\A4\E3\83\AB *****\0A\00"
@.str.4 = [12 x i8] c"%4d%31s%10d\00"
@EOF = global i64 0
@SEEK_SET = global i32 0
@.str.5 = [10 x i8] c"%d %s %d\0A\00"
@.str.6 = [46 x i8] c"\0A\E5\87\BA\E5\8A\9B\E3\81\97\E3\81\9F\E3\81\84\E3\83\AC\E3\82\B3\E3\83\BC\E3\83\89\E7\95\AA\E5\8F\B7\E3\82\92\E5\85\A5\E5\8A\9B: \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [13 x i8] c"%4d%31s%10d\0A\00"
@.str.9 = [4 x i8] c"%s\0A\00"
@.str.10 = [62 x i8] c"\E8\A9\B2\E5\BD\93\E3\81\99\E3\82\8B\E3\83\AC\E3\82\B3\E3\83\BC\E3\83\89\E3\81\8C\E8\A6\8B\E3\81\A4\E3\81\8B\E3\82\8A\E3\81\BE\E3\81\9B\E3\82\93\E3\81\A7\E3\81\97\E3\81\9F\E3\80\82\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [31 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
%7 = load i32*, i32** %2
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %14
14: ; preds = %20, %12
%15 = load i32*, i32** %2
%16 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 0
%17 = call i64 @fscanf(i32* %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32* %5, i8* %16, i32* %4)
%18 = load i64, i64* @EOF
%19 = icmp ne i64 %17, %18
br i1 %19, label %20, label %30
20: ; preds = %14
%21 = load i32*, i32** %2
%22 = load i32, i32* %5
%23 = mul nsw i32 %22, 47
%24 = load i32, i32* @SEEK_SET
%25 = call i32 @fseek(i32* %21, i32 %23, i32 %24)
%26 = load i32, i32* %5
%27 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 0
%28 = load i32, i32* %4
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %26, i8* %27, i32 %28)
br label %14
30: ; preds = %14
%31 = load i32*, i32** %2
%32 = call i32 @fclose(i32* %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0))
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %5)
%35 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %35, i32** %2
%36 = load i32*, i32** %2
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %41
38: ; preds = %30
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %30
%42 = load i32*, i32** %2
%43 = load i32, i32* %5
%44 = sub nsw i32 %43, 1
%45 = mul nsw i32 %44, 47
%46 = load i32, i32* @SEEK_SET
%47 = call i32 @fseek(i32* %42, i32 %45, i32 %46)
%48 = load i32*, i32** %2
%49 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 0
%50 = call i64 @fscanf(i32* %48, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32* %5, i8* %49, i32* %4)
%51 = load i64, i64* @EOF
%52 = icmp ne i64 %50, %51
br i1 %52, label %53, label %56
53: ; preds = %41
%54 = getelementptr inbounds [31 x i8], [31 x i8]* %3, i64 0, i64 0
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %54)
br label %58
56: ; preds = %41
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.10, i64 0, i64 0))
br label %58
58: ; preds = %56, %53
%59 = load i32*, i32** %2
%60 = call i32 @fclose(i32* %59)
%61 = load i32, i32* %1
ret i32 %61
}

LLVM IR (-O2):
@.str = [11 x i8] c"syohin.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.4 = [12 x i8] c"%4d%31s%10d\00"
@EOF = global i64 0
@SEEK_SET = global i32 0
@.str.5 = [10 x i8] c"%d %s %d\0A\00"
@.str.6 = [46 x i8] c"\0A\E5\87\BA\E5\8A\9B\E3\81\97\E3\81\9F\E3\81\84\E3\83\AC\E3\82\B3\E3\83\BC\E3\83\89\E7\95\AA\E5\8F\B7\E3\82\92\E5\85\A5\E5\8A\9B: \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [13 x i8] c"%4d%31s%10d\0A\00"
@str = [31 x i8] c"***** \E5\95\86\E5\93\81\E3\83\95\E3\82\A1\E3\82\A4\E3\83\AB *****\00"
@str.11 = [61 x i8] c"\E8\A9\B2\E5\BD\93\E3\81\99\E3\82\8B\E3\83\AC\E3\82\B3\E3\83\BC\E3\83\89\E3\81\8C\E8\A6\8B\E3\81\A4\E3\81\8B\E3\82\8A\E3\81\BE\E3\81\9B\E3\82\93\E3\81\A7\E3\81\97\E3\81\9F\E3\80\82\00"
@str.13 = [46 x i8] c"\E3\83\95\E3\82\A1\E3\82\A4\E3\83\AB\E3\81\8C\E3\82\AA\E3\83\BC\E3\83\97\E3\83\B3\E3\81\A7\E3\81\8D\E3\81\BE\E3\81\9B\E3\82\93\E3\80\82\00"
define i32 @main() {
%1 = alloca [31 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = getelementptr inbounds [31 x i8], [31 x i8]* %1, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.13, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %0
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%14 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32* %3, i8* %4, i32* %2)
%15 = load i64, i64* @EOF
%16 = icmp eq i64 %14, %15
br i1 %16, label %28, label %17
17: ; preds = %12, %17
%18 = load i32, i32* %3
%19 = mul nsw i32 %18, 47
%20 = load i32, i32* @SEEK_SET
%21 = call i32 @fseek(i32* %7, i32 %19, i32 %20)
%22 = load i32, i32* %3
%23 = load i32, i32* %2
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %22, i8* %4, i32 %23)
%25 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32* %3, i8* %4, i32* %2)
%26 = load i64, i64* @EOF
%27 = icmp eq i64 %25, %26
br i1 %27, label %28, label %17
28: ; preds = %17, %12
%29 = call i32 @fclose(i32* %7)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %3)
%32 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.13, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %28
%38 = load i32, i32* %3
%39 = mul i32 %38, 47
%40 = add i32 %39, -47
%41 = load i32, i32* @SEEK_SET
%42 = call i32 @fseek(i32* %32, i32 %40, i32 %41)
%43 = call i64 @fscanf(i32* %32, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32* %3, i8* %4, i32* %2)
%44 = load i64, i64* @EOF
%45 = icmp eq i64 %43, %44
br i1 %45, label %48, label %46
46: ; preds = %37
%47 = call i32 @puts(i8* %4)
br label %50
48: ; preds = %37
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str.11, i64 0, i64 0))
br label %50
50: ; preds = %48, %46
%51 = call i32 @fclose(i32* %32)
ret i32 0
}