#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__ isdigit(char);
char *malloc(int);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *make_effort(char *data) {
  char *effort;
  int limit, i, num = 0, len, off;
  limit = 12;
  len = strlen(data);
  off = len;
  for (i = 0; i < len; i++) {
    if (isdigit(data[i]))
      num += 4;
    else
      num++;
    if (num > limit) {
      off = i + 1;
      break;
    }
  }
  if (off < 1)
    off = 1;
  effort = malloc(off + 1);
  strncpy(effort, data, off);
  effort[off] = '\0';
  return effort;
}


x86 assembly (clang, -O0):
<make_effort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0xc,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11de <make_effort+0x9e>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     11a8 <make_effort+0x68>
mov    -0x1c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b1 <make_effort+0x71>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    11cb <make_effort+0x8b>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11de <make_effort+0x9e>
jmp    11d0 <make_effort+0x90>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1173 <make_effort+0x33>
cmpl   $0x1,-0x24(%rbp)
jge    11ef <make_effort+0xaf>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_effort>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <strlen@plt>
mov    %eax,%r15d
test   %eax,%eax
jle    1193 <make_effort+0x53>
xor    %ebx,%ebx
xor    %r12d,%r12d
nopl   0x0(%rax)
movsbl (%r14,%rbx,1),%edi
call   1040 <isdigit@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    (%rcx,%rcx,2),%eax
add    %eax,%r12d
add    $0x1,%r12d
cmp    $0xd,%r12d
jae    118d <make_effort+0x4d>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <make_effort+0x20>
jmp    1193 <make_effort+0x53>
add    $0x1,%ebx
mov    %ebx,%r15d
test   %r15d,%r15d
mov    $0x1,%r12d
cmovg  %r15d,%r12d
lea    0x1(%r12),%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
call   1030 <strncpy@plt>
movb   $0x0,(%r15,%r12,1)
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @make_effort(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %6
store i32 12, i32* %4
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %7
%11 = load i32, i32* %7
store i32 %11, i32* %8
store i32 0, i32* %5
br label %12
12: ; preds = %38, %1
%13 = load i32, i32* %5
%14 = load i32, i32* %7
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %41
16: ; preds = %12
%17 = load i8*, i8** %2
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = call i64 @isdigit(i8 signext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %16
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 4
store i32 %26, i32* %6
br label %30
27: ; preds = %16
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %30
30: ; preds = %27, %24
%31 = load i32, i32* %6
%32 = load i32, i32* %4
%33 = icmp sgt i32 %31, %32
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %8
br label %41
37: ; preds = %30
br label %38
38: ; preds = %37
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %12
41: ; preds = %34, %12
%42 = load i32, i32* %8
%43 = icmp slt i32 %42, 1
br i1 %43, label %44, label %45
44: ; preds = %41
store i32 1, i32* %8
br label %45
45: ; preds = %44, %41
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
%48 = call i8* @malloc(i32 %47)
store i8* %48, i8** %3
%49 = load i8*, i8** %3
%50 = load i8*, i8** %2
%51 = load i32, i32* %8
%52 = call i32 @strncpy(i8* %49, i8* %50, i32 %51)
%53 = load i8*, i8** %3
%54 = load i32, i32* %8
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
store i8 0, i8* %56
%57 = load i8*, i8** %3
ret i8* %57
}

LLVM IR (-O2):
define i8* @make_effort(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %22
4: ; preds = %1
%5 = zext i32 %2 to i64
br label %6
6: ; preds = %4, %19
%7 = phi i64 [ 0, %4 ], [ %20, %19 ]
%8 = phi i32 [ 0, %4 ], [ %14, %19 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %7
%10 = load i8, i8* %9
%11 = tail call i64 @isdigit(i8 signext %10)
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i32 1, i32 4
%14 = add nuw nsw i32 %13, %8
%15 = icmp ugt i32 %14, 12
br i1 %15, label %16, label %19
16: ; preds = %6
%17 = trunc i64 %7 to i32
%18 = add nuw nsw i32 %17, 1
br label %22
19: ; preds = %6
%20 = add nuw nsw i64 %7, 1
%21 = icmp eq i64 %20, %5
br i1 %21, label %22, label %6
22: ; preds = %19, %1, %16
%23 = phi i32 [ %18, %16 ], [ %2, %1 ], [ %2, %19 ]
%24 = icmp sgt i32 %23, 1
%25 = select i1 %24, i32 %23, i32 1
%26 = add nuw nsw i32 %25, 1
%27 = tail call i8* @malloc(i32 %26)
%28 = tail call i32 @strncpy(i8* %27, i8* %0, i32 %25)
%29 = zext i32 %25 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
store i8 0, i8* %30
ret i8* %27
}