#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 /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char *argv[]) {
  int fuck, shit = 0, suck;
  scanf("%d", &fuck);
  while (shit * 4 <= fuck) {
    if (!((fuck - shit * 4) % 7)) {
      suck = (fuck - shit * 4) / 7;
      while (shit--)
        printf("4");
      while (suck--)
        printf("7");
      return 0;
    }
    shit++;
  }
  printf("-1");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xebc(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x18(%rbp),%eax
shl    $0x2,%eax
cmp    -0x14(%rbp),%eax
jg     11f7 <main+0xd7>
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
shl    $0x2,%ecx
sub    %ecx,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11e9 <main+0xc9>
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
shl    $0x2,%ecx
sub    %ecx,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x18(%rbp)
cmp    $0x0,%eax
je     11b3 <main+0x93>
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
jmp    118e <main+0x6e>
jmp    11b8 <main+0x98>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
je     11dd <main+0xbd>
lea    0xe32(%rip),%rdi
call   1030 <printf@plt>
jmp    11b8 <main+0x98>
movl   $0x0,-0x4(%rbp)
jmp    120a <main+0xea>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114d <main+0x2d>
lea    0xe09(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%r14d
test   %r14d,%r14d
js     1182 <main+0x52>
xor    %ebp,%ebp
mov    %r14d,%r15d
xor    %ebx,%ebx
nopl   0x0(%rax)
imul   $0xb6db6db7,%r15d,%eax
add    $0x12492492,%eax
cmp    $0x24924924,%eax
jbe    1190 <main+0x60>
add    $0xffffffff,%ebx
add    $0x4,%ebp
add    $0xfffffffc,%r15d
cmp    %ebp,%r14d
jge    1160 <main+0x30>
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
jmp    11ef <main+0xbf>
test   %ebx,%ebx
je     11ae <main+0x7e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x34,%edi
call   1030 <putchar@plt>
inc    %ebx
jne    11a0 <main+0x70>
sub    %ebp,%r14d
add    $0x6,%r14d
cmp    $0xd,%r14d
jb     11ef <main+0xbf>
movslq %r15d,%rax
imul   $0xffffffff92492493,%rax,%rbx
shr    $0x20,%rbx
add    %r15d,%ebx
mov    %ebx,%eax
shr    $0x1f,%eax
sar    $0x2,%ebx
add    %eax,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    $0x37,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    11e0 <main+0xb0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"4\00"
@.str.2 = [2 x i8] c"7\00"
@.str.3 = [3 x i8] c"-1\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
br label %10
10: ; preds = %42, %2
%11 = load i32, i32* %7
%12 = mul nsw i32 %11, 4
%13 = load i32, i32* %6
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %45
15: ; preds = %10
%16 = load i32, i32* %6
%17 = load i32, i32* %7
%18 = mul nsw i32 %17, 4
%19 = sub nsw i32 %16, %18
%20 = srem i32 %19, 7
%21 = icmp ne i32 %20, 0
br i1 %21, label %42, label %22
22: ; preds = %15
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = mul nsw i32 %24, 4
%26 = sub nsw i32 %23, %25
%27 = sdiv i32 %26, 7
store i32 %27, i32* %8
br label %28
28: ; preds = %32, %22
%29 = load i32, i32* %7
%30 = add nsw i32 %29, -1
store i32 %30, i32* %7
%31 = icmp ne i32 %29, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %28
34: ; preds = %28
br label %35
35: ; preds = %39, %34
%36 = load i32, i32* %8
%37 = add nsw i32 %36, -1
store i32 %37, i32* %8
%38 = icmp ne i32 %36, 0
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %35
41: ; preds = %35
store i32 0, i32* %3
br label %47
42: ; preds = %15
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %10
45: ; preds = %10
%46 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %47
47: ; preds = %45, %41
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"-1\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %34, label %8
8: ; preds = %2, %30
%9 = phi i32 [ %32, %30 ], [ 0, %2 ]
%10 = phi i32 [ %31, %30 ], [ 0, %2 ]
%11 = sub nsw i32 %6, %9
%12 = srem i32 %11, 7
%13 = sdiv i32 %11, 7
%14 = icmp eq i32 %12, 0
br i1 %14, label %15, label %30
15: ; preds = %8
%16 = icmp eq i32 %10, 0
br i1 %16, label %17, label %20
17: ; preds = %20, %15
%18 = add i32 %11, 6
%19 = icmp ult i32 %18, 13
br i1 %19, label %36, label %25
20: ; preds = %15, %20
%21 = phi i32 [ %22, %20 ], [ %10, %15 ]
%22 = add nsw i32 %21, -1
%23 = call i32 @putchar(i32 52)
%24 = icmp eq i32 %22, 0
br i1 %24, label %17, label %20
25: ; preds = %17, %25
%26 = phi i32 [ %27, %25 ], [ %13, %17 ]
%27 = add nsw i32 %26, -1
%28 = call i32 @putchar(i32 55)
%29 = icmp eq i32 %27, 0
br i1 %29, label %36, label %25
30: ; preds = %8
%31 = add nuw nsw i32 %10, 1
%32 = shl nsw i32 %31, 2
%33 = icmp slt i32 %6, %32
br i1 %33, label %34, label %8
34: ; preds = %30, %2
%35 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %25, %17, %34
ret i32 0
}