#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 */
scalar_t__ EOF;
int cutSticks(int *, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ scanf(char *, int *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int main(int argc, const char *argv[]) {
  int length, i;
  int numOfCuts;
  char result[1000];
  while (scanf("%d", &length) != EOF) {
    if (length == 0)
      break;
    scanf("%d", &numOfCuts);
    int cuts[numOfCuts];
    for (i = 0; i != numOfCuts; i++)
      scanf("%d", &cuts[i]);
    int currNum = cutSticks(cuts, length, 0, numOfCuts);
    char currResult[50];
    sprintf(currResult, "The minimum cutting is %d.\n", currNum);
    strcat(result, currResult);
  }
  printf("%s", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe90(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2e68(%rip),%rcx
cmp    (%rcx),%rax
je     126c <main+0x11c>
cmpl   $0x0,-0x14(%rbp)
jne    1198 <main+0x48>
jmp    126c <main+0x11c>
lea    0xe61(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x418(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x468(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x420(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     1217 <main+0xc7>
mov    -0x468(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xdfc(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11df <main+0x8f>
mov    -0x468(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%ecx
xor    %edx,%edx
call   1050 <cutSticks@plt>
mov    %eax,-0x424(%rbp)
lea    -0x460(%rbp),%rdi
mov    -0x424(%rbp),%edx
lea    0xdbe(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x410(%rbp),%rdi
lea    -0x460(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x418(%rbp),%rax
mov    %rax,%rsp
jmp    1169 <main+0x19>
lea    -0x410(%rbp),%rsi
lea    0xda5(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x438,%rsp
lea    0xe95(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2e6d(%rip),%rcx
cmp    (%rcx),%rax
je     1251 <main+0x101>
cmpl   $0x0,-0x2c(%rbp)
je     1251 <main+0x101>
lea    0xe6b(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
lea    -0x30(%rbp),%rsi
call   1040 <scanf@plt>
mov    %rsp,%r14
mov    -0x30(%rbp),%eax
mov    %rsp,%r13
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
cmpl   $0x0,-0x30(%rbp)
mov    $0x0,%ecx
je     11fb <main+0xab>
mov    %r13,%r15
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
add    $0x1,%r12
mov    -0x30(%rbp),%ecx
add    $0x4,%r15
cmp    %rcx,%r12
jne    11e0 <main+0x90>
mov    -0x2c(%rbp),%esi
mov    %r13,%rdi
xor    %edx,%edx
call   1050 <cutSticks@plt>
lea    -0x70(%rbp),%r15
mov    %r15,%rdi
lea    0xded(%rip),%rsi
mov    %eax,%edx
call   1070 <sprintf@plt>
lea    -0x460(%rbp),%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
mov    %r14,%rsp
mov    %rbx,%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2da6(%rip),%rcx
cmp    (%rcx),%rax
je     1251 <main+0x101>
cmpl   $0x0,-0x2c(%rbp)
jne    11a0 <main+0x50>
lea    0xdc7(%rip),%rdi
lea    -0x460(%rbp),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [28 x i8] c"The minimum cutting is %d.\0A\00"
@.str.2 = [3 x i8] c"%s\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
%9 = alloca [1000 x i8]
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
%13 = alloca [50 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %14
14: ; preds = %40, %2
%15 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%16 = load i64, i64* @EOF
%17 = icmp ne i64 %15, %16
br i1 %17, label %18, label %51
18: ; preds = %14
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %18
br label %51
22: ; preds = %18
%23 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%24 = load i32, i32* %8
%25 = zext i32 %24 to i64
%26 = call i8* @llvm.stacksave()
store i8* %26, i8** %10
%27 = alloca i32, i64 %25
store i64 %25, i64* %11
store i32 0, i32* %7
br label %28
28: ; preds = %37, %22
%29 = load i32, i32* %7
%30 = load i32, i32* %8
%31 = icmp ne i32 %29, %30
br i1 %31, label %32, label %40
32: ; preds = %28
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %27, i64 %34
%36 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %35)
br label %37
37: ; preds = %32
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %28
40: ; preds = %28
%41 = load i32, i32* %6
%42 = load i32, i32* %8
%43 = call i32 @cutSticks(i32* %27, i32 %41, i32 0, i32 %42)
store i32 %43, i32* %12
%44 = getelementptr inbounds [50 x i8], [50 x i8]* %13, i64 0, i64 0
%45 = load i32, i32* %12
%46 = call i32 @sprintf(i8* %44, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %45)
%47 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%48 = getelementptr inbounds [50 x i8], [50 x i8]* %13, i64 0, i64 0
%49 = call i32 @strcat(i8* %47, i8* %48)
%50 = load i8*, i8** %10
br label %14
51: ; preds = %21, %14
%52 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%53 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %52)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [28 x i8] c"The minimum cutting is %d.\0A\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [1000 x i8]
%6 = alloca [50 x i8]
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%10 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%11 = load i64, i64* @EOF
%12 = icmp eq i64 %10, %11
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 0
%15 = select i1 %12, i1 true, i1 %14
br i1 %15, label %46, label %16
16: ; preds = %2
%17 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
br label %18
18: ; preds = %16, %34
%19 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%20 = load i32, i32* %4
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
%23 = alloca i32, i64 %21
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 0
br i1 %25, label %34, label %26
26: ; preds = %18, %26
%27 = phi i64 [ %30, %26 ], [ 0, %18 ]
%28 = getelementptr inbounds i32, i32* %23, i64 %27
%29 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %28)
%30 = add nuw i64 %27, 1
%31 = load i32, i32* %4
%32 = zext i32 %31 to i64
%33 = icmp eq i64 %30, %32
br i1 %33, label %34, label %26
34: ; preds = %26, %18
%35 = phi i32 [ 0, %18 ], [ %31, %26 ]
%36 = load i32, i32* %3
%37 = call i32 @cutSticks(i32* %23, i32 %36, i32 0, i32 %35)
%38 = call i32 @sprintf(i8* %17, i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = call i32 @strcat(i8* %9, i8* %17)
%40 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%41 = load i64, i64* @EOF
%42 = icmp eq i64 %40, %41
%43 = load i32, i32* %3
%44 = icmp eq i32 %43, 0
%45 = select i1 %42, i1 true, i1 %44
br i1 %45, label %46, label %18
46: ; preds = %34, %2
%47 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %9)
ret i32 0
}