#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*/ CarList_Change();
scalar_t__ Car_GetCarAxlesNum(int /*<<< orphan*/);
int Car_GetCarListWeight();
int Car_GetCarWeight(int);
scalar_t__ Car_GetNum();
int /*<<< orphan*/ ModfiyCarAxlesByWeight(int /*<<< orphan*/, int);
int /*<<< orphan*/ ModifyAxlesNo(int);
void ModfiyAxlesByWeight(int InputWeight) {
  int i = 0;
  int tempWeight = 0;
  int axle = 0;
  if (Car_GetNum() > 0) {
    if (InputWeight > Car_GetCarListWeight() || InputWeight <= 0) {
      return;
    }
    if (InputWeight <= Car_GetCarWeight(0)) {
      ModfiyCarAxlesByWeight(0, InputWeight);
    } else {
      do {
        tempWeight += Car_GetCarWeight(i);
        axle += Car_GetCarAxlesNum(i++);
      } while (tempWeight < InputWeight);
      ModifyAxlesNo(axle);
      ModfiyCarAxlesByWeight(0, InputWeight);
    }
  }
  CarList_Change();
}


x86 assembly (clang, -O0):
<ModfiyAxlesByWeight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1070 <Car_GetNum@plt>
cmp    $0x0,%rax
jle    1246 <ModfiyAxlesByWeight+0xd6>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1090 <Car_GetCarListWeight@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jg     11c5 <ModfiyAxlesByWeight+0x55>
cmpl   $0x0,-0x4(%rbp)
jg     11ca <ModfiyAxlesByWeight+0x5a>
jmp    124d <ModfiyAxlesByWeight+0xdd>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
xor    %edi,%edi
call   1050 <Car_GetCarWeight@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jg     11f3 <ModfiyAxlesByWeight+0x83>
mov    -0x4(%rbp),%esi
xor    %edi,%edi
call   1040 <ModfiyCarAxlesByWeight@plt>
jmp    1241 <ModfiyAxlesByWeight+0xd1>
jmp    11f8 <ModfiyAxlesByWeight+0x88>
mov    -0x8(%rbp),%edi
call   1050 <Car_GetCarWeight@plt>
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    %edi,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
call   1030 <Car_GetCarAxlesNum@plt>
mov    %rax,%rcx
movslq -0x10(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     11f8 <ModfiyAxlesByWeight+0x88>
mov    -0x10(%rbp),%edi
call   1060 <ModifyAxlesNo@plt>
mov    -0x4(%rbp),%esi
xor    %edi,%edi
call   1040 <ModfiyCarAxlesByWeight@plt>
jmp    1246 <ModfiyAxlesByWeight+0xd6>
mov    $0x0,%al
call   1080 <CarList_Change@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ModfiyAxlesByWeight>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r14d
xor    %eax,%eax
call   1070 <Car_GetNum@plt>
test   %rax,%rax
jle    11e5 <ModfiyAxlesByWeight+0x75>
xor    %eax,%eax
call   1090 <Car_GetCarListWeight@plt>
test   %r14d,%r14d
jle    11f4 <ModfiyAxlesByWeight+0x84>
cmp    %r14d,%eax
jl     11f4 <ModfiyAxlesByWeight+0x84>
xor    %r15d,%r15d
xor    %edi,%edi
call   1050 <Car_GetCarWeight@plt>
cmp    %r14d,%eax
jge    11db <ModfiyAxlesByWeight+0x6b>
xor    %ebp,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
call   1050 <Car_GetCarWeight@plt>
add    %eax,%ebp
lea    0x1(%r15),%r12d
mov    %r15d,%edi
call   1030 <Car_GetCarAxlesNum@plt>
movslq %ebx,%rbx
add    %rax,%rbx
mov    %r12d,%r15d
cmp    %r14d,%ebp
jl     11b0 <ModfiyAxlesByWeight+0x40>
mov    %ebx,%edi
call   1060 <ModifyAxlesNo@plt>
xor    %edi,%edi
mov    %r14d,%esi
call   1040 <ModfiyCarAxlesByWeight@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <CarList_Change@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ModfiyAxlesByWeight(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = call i64 (...) @Car_GetNum()
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, label %46
8: ; preds = %1
%9 = load i32, i32* %2
%10 = call i32 (...) @Car_GetCarListWeight()
%11 = icmp sgt i32 %9, %10
br i1 %11, label %15, label %12
12: ; preds = %8
%13 = load i32, i32* %2
%14 = icmp sle i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12, %8
br label %48
16: ; preds = %12
%17 = load i32, i32* %2
%18 = call i32 @Car_GetCarWeight(i32 0)
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i32, i32* %2
%22 = call i32 @ModfiyCarAxlesByWeight(i32 0, i32 %21)
br label %45
23: ; preds = %16
br label %24
24: ; preds = %36, %23
%25 = load i32, i32* %3
%26 = call i32 @Car_GetCarWeight(i32 %25)
%27 = load i32, i32* %4
%28 = add nsw i32 %27, %26
store i32 %28, i32* %4
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
%31 = call i64 @Car_GetCarAxlesNum(i32 %29)
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = add nsw i64 %33, %31
%35 = trunc i64 %34 to i32
store i32 %35, i32* %5
br label %36
36: ; preds = %24
%37 = load i32, i32* %4
%38 = load i32, i32* %2
%39 = icmp slt i32 %37, %38
br i1 %39, label %24, label %40
40: ; preds = %36
%41 = load i32, i32* %5
%42 = call i32 @ModifyAxlesNo(i32 %41)
%43 = load i32, i32* %2
%44 = call i32 @ModfiyCarAxlesByWeight(i32 0, i32 %43)
br label %45
45: ; preds = %40, %20
br label %46
46: ; preds = %45, %1
%47 = call i32 (...) @CarList_Change()
br label %48
48: ; preds = %46, %15
ret void
}

LLVM IR (-O2):
define void @ModfiyAxlesByWeight(i32 %0) {
%2 = tail call i64 (...) @Car_GetNum()
%3 = icmp sgt i64 %2, 0
br i1 %3, label %4, label %29
4: ; preds = %1
%5 = tail call i32 (...) @Car_GetCarListWeight()
%6 = icmp slt i32 %5, %0
%7 = icmp slt i32 %0, 1
%8 = or i1 %7, %6
br i1 %8, label %31, label %9
9: ; preds = %4
%10 = tail call i32 @Car_GetCarWeight(i32 0)
%11 = icmp slt i32 %10, %0
br i1 %11, label %12, label %27
12: ; preds = %9, %12
%13 = phi i32 [ %18, %12 ], [ 0, %9 ]
%14 = phi i32 [ %17, %12 ], [ 0, %9 ]
%15 = phi i64 [ %22, %12 ], [ 0, %9 ]
%16 = tail call i32 @Car_GetCarWeight(i32 %13)
%17 = add nsw i32 %16, %14
%18 = add nuw nsw i32 %13, 1
%19 = tail call i64 @Car_GetCarAxlesNum(i32 %13)
%20 = shl i64 %15, 32
%21 = ashr exact i64 %20, 32
%22 = add nsw i64 %21, %19
%23 = icmp slt i32 %17, %0
br i1 %23, label %12, label %24
24: ; preds = %12
%25 = trunc i64 %22 to i32
%26 = tail call i32 @ModifyAxlesNo(i32 %25)
br label %27
27: ; preds = %9, %24
%28 = tail call i32 @ModfiyCarAxlesByWeight(i32 0, i32 %0)
br label %29
29: ; preds = %27, %1
%30 = tail call i32 (...) @CarList_Change()
br label %31
31: ; preds = %4, %29
ret void
}