#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 *, char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int number;
  int flag = 1;
  int numA;
  int numB;
  int numC;
  int numD;
  int numE;
  int counter = 0;
  printf("%s", "Enter a valid number (up to 5 digits): ");
  scanf("%d", &number);
  while (flag != -1) {
    if (number >= 0) {
      if (number <= 99999) {
        numA = number / 10000;
        number = number % 10000;
        numB = number / 1000;
        number = number % 1000;
        numC = number / 100;
        number = number % 100;
        numD = number / 10;
        number = number % 10;
        numE = number;
        if (numA == 7) {
          counter++;
        }
        if (numB == 7) {
          counter++;
        }
        if (numC == 7) {
          counter++;
        }
        if (numD == 7) {
          counter++;
        }
        if (numE == 7) {
          counter++;
        }
        flag = -1;
      } else {
        puts("You have not entered a valid number");
        printf("%s", "Enter a valid number (up to 5 digits): ");
        scanf("%d", &number);
        flag = 1;
      }
    } else {
      puts("You have not entered a valid number");
      printf("%s", "Enter a valid number (up to 5 digits): ");
      scanf("%d", &number);
      flag = 1;
    }
  }
  if (counter > 0) {
    printf("%s%d", "The sevens found are: ", counter);
  } else {
    printf("%s", "No sevens where found!!!");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xeac(%rip),%rdi
lea    0xea8(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0xffffffff,-0xc(%rbp)
je     12ee <main+0x1be>
cmpl   $0x0,-0x8(%rbp)
jl     12b1 <main+0x181>
cmpl   $0x1869f,-0x8(%rbp)
jg     1274 <main+0x144>
mov    -0x8(%rbp),%eax
mov    $0x2710,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2710,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x7,-0x10(%rbp)
jne    121c <main+0xec>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x7,-0x14(%rbp)
jne    122f <main+0xff>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x7,-0x18(%rbp)
jne    1242 <main+0x112>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x7,-0x1c(%rbp)
jne    1255 <main+0x125>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x7,-0x20(%rbp)
jne    1268 <main+0x138>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movl   $0xffffffff,-0xc(%rbp)
jmp    12ac <main+0x17c>
lea    0xdb0(%rip),%rdi
call   1030 <puts@plt>
lea    0xd79(%rip),%rdi
lea    0xd75(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdb5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x1,-0xc(%rbp)
jmp    12e9 <main+0x1b9>
lea    0xd73(%rip),%rdi
call   1030 <puts@plt>
lea    0xd3c(%rip),%rdi
lea    0xd38(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd78(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x1,-0xc(%rbp)
jmp    1172 <main+0x42>
cmpl   $0x0,-0x24(%rbp)
jle    1315 <main+0x1e5>
mov    -0x24(%rbp),%edx
lea    0xd4d(%rip),%rdi
lea    0xd4b(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    132a <main+0x1fa>
lea    0xce4(%rip),%rdi
lea    0xd48(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebc(%rip),%rdi
lea    0xeb8(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x186a0,%eax
jb     11bb <main+0x8b>
lea    0xeb6(%rip),%r14
lea    0xe84(%rip),%r15
lea    0xe80(%rip),%r12
lea    0xec7(%rip),%r13
lea    0xc(%rsp),%rbx
nop
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x1869f,%eax
ja     1190 <main+0x60>
mov    %eax,%ecx
mov    $0xd1b71759,%edx
imul   %rcx,%rdx
shr    $0x2d,%rdx
imul   $0x2710,%edx,%ecx
mov    %eax,%edx
sub    %ecx,%edx
movzwl %dx,%esi
shr    $0x3,%esi
imul   $0x20c5,%esi,%esi
shr    $0x14,%esi
imul   $0x3e8,%esi,%esi
sub    %esi,%edx
movzwl %dx,%edx
mov    %edx,%esi
shr    $0x2,%esi
imul   $0x147b,%esi,%esi
shr    $0x11,%esi
imul   $0x64,%esi,%esi
mov    %edx,%edi
sub    %esi,%edi
movzwl %di,%esi
imul   $0xcd,%edi,%ebx
shr    $0xa,%ebx
and    $0x3e,%ebx
lea    (%rbx,%rbx,4),%ebx
sub    %bl,%dil
movzbl %dil,%r8d
mov    %r8d,0xc(%rsp)
lea    -0x11170(%rax),%ebx
xor    %edi,%edi
cmp    $0x2710,%ebx
setb   %dil
neg    %ecx
add    %ecx,%eax
add    $0xffffe4a8,%eax
cmp    $0x3e8,%eax
adc    $0x0,%edi
add    $0xfffffd44,%edx
cmp    $0x64,%edx
adc    $0x0,%edi
add    $0xffffffba,%esi
cmp    $0xa,%esi
adc    $0x0,%edi
xor    %edx,%edx
cmp    $0x7,%r8b
sete   %dl
add    %edi,%edx
je     127d <main+0x14d>
lea    0xde2(%rip),%rdi
lea    0xde0(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1292 <main+0x162>
lea    0xd7c(%rip),%rdi
lea    0xde0(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [40 x i8] c"Enter a valid number (up to 5 digits): \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [36 x i8] c"You have not entered a valid number\00"
@.str.4 = [5 x i8] c"%s%d\00"
@.str.5 = [23 x i8] c"The sevens found are: \00"
@.str.6 = [25 x i8] c"No sevens where found!!!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %3
store i32 0, i32* %9
%10 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
br label %12
12: ; preds = %78, %0
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %79
15: ; preds = %12
%16 = load i32, i32* %2
%17 = icmp sge i32 %16, 0
br i1 %17, label %18, label %74
18: ; preds = %15
%19 = load i32, i32* %2
%20 = icmp sle i32 %19, 99999
br i1 %20, label %21, label %69
21: ; preds = %18
%22 = load i32, i32* %2
%23 = sdiv i32 %22, 10000
store i32 %23, i32* %4
%24 = load i32, i32* %2
%25 = srem i32 %24, 10000
store i32 %25, i32* %2
%26 = load i32, i32* %2
%27 = sdiv i32 %26, 1000
store i32 %27, i32* %5
%28 = load i32, i32* %2
%29 = srem i32 %28, 1000
store i32 %29, i32* %2
%30 = load i32, i32* %2
%31 = sdiv i32 %30, 100
store i32 %31, i32* %6
%32 = load i32, i32* %2
%33 = srem i32 %32, 100
store i32 %33, i32* %2
%34 = load i32, i32* %2
%35 = sdiv i32 %34, 10
store i32 %35, i32* %7
%36 = load i32, i32* %2
%37 = srem i32 %36, 10
store i32 %37, i32* %2
%38 = load i32, i32* %2
store i32 %38, i32* %8
%39 = load i32, i32* %4
%40 = icmp eq i32 %39, 7
br i1 %40, label %41, label %44
41: ; preds = %21
%42 = load i32, i32* %9
%43 = add nsw i32 %42, 1
store i32 %43, i32* %9
br label %44
44: ; preds = %41, %21
%45 = load i32, i32* %5
%46 = icmp eq i32 %45, 7
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
store i32 %49, i32* %9
br label %50
50: ; preds = %47, %44
%51 = load i32, i32* %6
%52 = icmp eq i32 %51, 7
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = load i32, i32* %9
%55 = add nsw i32 %54, 1
store i32 %55, i32* %9
br label %56
56: ; preds = %53, %50
%57 = load i32, i32* %7
%58 = icmp eq i32 %57, 7
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load i32, i32* %9
%61 = add nsw i32 %60, 1
store i32 %61, i32* %9
br label %62
62: ; preds = %59, %56
%63 = load i32, i32* %8
%64 = icmp eq i32 %63, 7
br i1 %64, label %65, label %68
65: ; preds = %62
%66 = load i32, i32* %9
%67 = add nsw i32 %66, 1
store i32 %67, i32* %9
br label %68
68: ; preds = %65, %62
store i32 -1, i32* %3
br label %73
69: ; preds = %18
%70 = call i32 @puts(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%71 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%72 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %73
73: ; preds = %69, %68
br label %78
74: ; preds = %15
%75 = call i32 @puts(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%76 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%77 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %78
78: ; preds = %74, %73
br label %12
79: ; preds = %12
%80 = load i32, i32* %9
%81 = icmp sgt i32 %80, 0
br i1 %81, label %82, label %85
82: ; preds = %79
%83 = load i32, i32* %9
%84 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %83)
br label %87
85: ; preds = %79
%86 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
br label %87
87: ; preds = %85, %82
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [40 x i8] c"Enter a valid number (up to 5 digits): \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [36 x i8] c"You have not entered a valid number\00"
@.str.4 = [5 x i8] c"%s%d\00"
@.str.5 = [23 x i8] c"The sevens found are: \00"
@.str.6 = [25 x i8] c"No sevens where found!!!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp ult i32 %5, 100000
br i1 %6, label %13, label %7
7: ; preds = %0, %7
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = icmp ult i32 %11, 100000
br i1 %12, label %13, label %7
13: ; preds = %7, %0
%14 = phi i32 [ %5, %0 ], [ %11, %7 ]
%15 = urem i32 %14, 10000
%16 = trunc i32 %15 to i16
%17 = urem i16 %16, 1000
%18 = zext i16 %17 to i32
%19 = urem i16 %17, 100
%20 = zext i16 %19 to i32
%21 = trunc i16 %19 to i8
%22 = urem i8 %21, 10
%23 = zext i8 %22 to i32
store i32 %23, i32* %1
%24 = add nsw i32 %14, -70000
%25 = icmp ult i32 %24, 10000
%26 = zext i1 %25 to i32
%27 = add nsw i32 %15, -7000
%28 = icmp ult i32 %27, 1000
%29 = zext i1 %28 to i32
%30 = add nuw nsw i32 %26, %29
%31 = add nsw i32 %18, -700
%32 = icmp ult i32 %31, 100
%33 = zext i1 %32 to i32
%34 = add nuw nsw i32 %30, %33
%35 = add nsw i32 %20, -70
%36 = icmp ult i32 %35, 10
%37 = zext i1 %36 to i32
%38 = add nuw nsw i32 %34, %37
%39 = icmp eq i8 %22, 7
%40 = zext i1 %39 to i32
%41 = add nuw nsw i32 %38, %40
%42 = icmp eq i32 %41, 0
br i1 %42, label %45, label %43
43: ; preds = %13
%44 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %41)
br label %47
45: ; preds = %13
%46 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
br label %47
47: ; preds = %45, %43
ret i32 0
}