#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 atoi(char *);
int /*<<< orphan*/ scanf(char *, char *);
int valid(int n) {
  for (int i = 0; i < n; i++) {
    char next[7];
    scanf("%s", next);
    if (next[0] != 'm' && atoi(next) != i + 1)
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<valid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1191 <valid+0x71>
lea    -0x13(%rbp),%rsi
lea    0xeb7(%rip),%rdi
call   1030 <scanf@plt>
movsbl -0x13(%rbp),%eax
cmp    $0x6d,%eax
je     117e <valid+0x5e>
lea    -0x13(%rbp),%rdi
call   1040 <atoi@plt>
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
je     117e <valid+0x5e>
movl   $0x0,-0x4(%rbp)
jmp    1198 <valid+0x78>
jmp    1183 <valid+0x63>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1132 <valid+0x12>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %ebp,%ebp
test   %edi,%edi
jle    117e <valid+0x5e>
mov    %edi,%r12d
mov    $0x1,%bl
lea    0xec2(%rip),%r14
lea    0x9(%rsp),%r15
jmp    115b <valid+0x3b>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
cmp    %r12d,%ebp
setl   %bl
je     1180 <valid+0x60>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <scanf@plt>
cmpb   $0x6d,0x9(%rsp)
je     1150 <valid+0x30>
mov    %r15,%rdi
call   1040 <atoi@plt>
add    $0x1,%ebp
cmp    %ebp,%eax
je     1153 <valid+0x33>
jmp    1180 <valid+0x60>
xor    %ebx,%ebx
not    %bl
movzbl %bl,%eax
and    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i32 @valid(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [7 x i8]
store i32 %0, i32* %3
store i32 0, i32* %4
br label %6
6: ; preds = %25, %1
%7 = load i32, i32* %4
%8 = load i32, i32* %3
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %28
10: ; preds = %6
%11 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 109
br i1 %16, label %17, label %24
17: ; preds = %10
%18 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%19 = call i32 @atoi(i8* %18)
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
%22 = icmp ne i32 %19, %21
br i1 %22, label %23, label %24
23: ; preds = %17
store i32 0, i32* %2
br label %29
24: ; preds = %17, %10
br label %25
25: ; preds = %24
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %6
28: ; preds = %6
store i32 1, i32* %2
br label %29
29: ; preds = %28, %23
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @valid(i32 %0) {
%2 = alloca [7 x i8]
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %23
4: ; preds = %1
%5 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
br label %6
6: ; preds = %4, %19
%7 = phi i1 [ true, %4 ], [ %21, %19 ]
%8 = phi i32 [ 0, %4 ], [ %20, %19 ]
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%10 = load i8, i8* %5
%11 = icmp eq i8 %10, 109
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = add nuw nsw i32 %8, 1
br label %19
14: ; preds = %6
%15 = call i32 @atoi(i8* %5)
%16 = add nuw nsw i32 %8, 1
%17 = icmp eq i32 %15, %16
br i1 %17, label %19, label %18
18: ; preds = %14
br label %23
19: ; preds = %12, %14
%20 = phi i32 [ %13, %12 ], [ %16, %14 ]
%21 = icmp slt i32 %20, %0
%22 = icmp eq i32 %20, %0
br i1 %22, label %23, label %6
23: ; preds = %19, %1, %18
%24 = phi i1 [ %7, %18 ], [ false, %1 ], [ %21, %19 ]
%25 = xor i1 %24, true
%26 = zext i1 %25 to i32
ret i32 %26
}