#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 */
typedef int /*<<< orphan*/ *MYSQL_ROW;
typedef int /*<<< orphan*/ MYSQL_RES;
typedef int /*<<< orphan*/ MYSQL;

/* Variables and functions */
int /*<<< orphan*/ LOG_INFO;
float atof(int /*<<< orphan*/);
int /*<<< orphan*/ *mysql_fetch_row(int /*<<< orphan*/ *);
int mysql_num_rows(int /*<<< orphan*/ *);
scalar_t__ mysql_query(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ *mysql_store_result(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, float, float, float, float, float,
                           float);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
int unreserveIngred(MYSQL *sql_con, MYSQL_ROW order_row) {
  MYSQL_ROW row;
  MYSQL_RES *result;
  int num_rows, i;
  float ingredLevelArray[6];
  float orderIngredArray[6];
  char *ingredLevelQuery = "SELECT ing0, ing1, ing2, ing3, ing4, ing5 FROM "
                           "orderTable WHERE orderID=\"0\"";
  char queryString[300];
  if (mysql_query(sql_con, ingredLevelQuery)) {
    syslog(LOG_INFO, "ERROR: Unable to query SQL to find expired orders");
    return 1;
  }
  result = mysql_store_result(sql_con);
  if (result == NULL) {
    syslog(LOG_INFO, "ERROR: Unable to get expired results.");
    return 1;
  }
  num_rows = mysql_num_rows(result);
  if (num_rows < 0) {
    syslog(LOG_INFO, "Error: Invalid number of rows: %d", num_rows);
    return 1;
  } else if (num_rows != 1) {
    syslog(LOG_INFO, "Error: Too many ingredient level rows returned.");
    return 1;
  }
  row = mysql_fetch_row(result);
  for (i = 0; i < 6; ++i) {
    ingredLevelArray[i] = atof(row[i]);
    orderIngredArray[i] = atof(order_row[i]);
    ingredLevelArray[i] += orderIngredArray[i];
  }
  sprintf(queryString,
          "UPDATE orderTable SET ing0=%f, ing1=%f, ing2=%f, ing3=%f, ing4=%f, "
          "ing5=%f  WHERE orderID=\"0\"",
          ingredLevelArray[0], ingredLevelArray[1], ingredLevelArray[2],
          ingredLevelArray[3], ingredLevelArray[4], ingredLevelArray[5]);
  if (mysql_query(sql_con, queryString)) {
    syslog(LOG_INFO, "Error when updating Ingred values");
  }
  return 0;
}


x86 assembly (clang, -O0):
<unreserveIngred>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xe76(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   1040 <mysql_query@plt>
cmp    $0x0,%rax
je     11c8 <unreserveIngred+0x58>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    0xe97(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1354 <unreserveIngred+0x1e4>
mov    -0x10(%rbp),%rdi
call   1090 <mysql_store_result@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1203 <unreserveIngred+0x93>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
lea    0xe8e(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1354 <unreserveIngred+0x1e4>
mov    -0x28(%rbp),%rdi
call   1080 <mysql_num_rows@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    123f <unreserveIngred+0xcf>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xe78(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1354 <unreserveIngred+0x1e4>
cmpl   $0x1,-0x2c(%rbp)
je     126c <unreserveIngred+0xfc>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
lea    0xe6d(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
movl   $0x1,-0x4(%rbp)
jmp    1354 <unreserveIngred+0x1e4>
jmp    1271 <unreserveIngred+0x101>
mov    -0x28(%rbp),%rdi
call   1050 <mysql_fetch_row@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x6,-0x30(%rbp)
jge    12eb <unreserveIngred+0x17b>
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1030 <atof@plt>
movslq -0x30(%rbp),%rax
movss  %xmm0,-0x50(%rbp,%rax,4)
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1030 <atof@plt>
movslq -0x30(%rbp),%rax
movss  %xmm0,-0x70(%rbp,%rax,4)
movslq -0x30(%rbp),%rax
movss  -0x70(%rbp,%rax,4),%xmm0
movslq -0x30(%rbp),%rax
addss  -0x50(%rbp,%rax,4),%xmm0
movss  %xmm0,-0x50(%rbp,%rax,4)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1285 <unreserveIngred+0x115>
lea    -0x1b0(%rbp),%rdi
movss  -0x50(%rbp),%xmm0
movss  -0x4c(%rbp),%xmm1
movss  -0x48(%rbp),%xmm2
movss  -0x44(%rbp),%xmm3
movss  -0x40(%rbp),%xmm4
movss  -0x3c(%rbp),%xmm5
lea    0xddf(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1b0(%rbp),%rsi
call   1040 <mysql_query@plt>
cmp    $0x0,%rax
je     134d <unreserveIngred+0x1dd>
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
lea    0xe0e(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unreserveIngred>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x158,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xe75(%rip),%rsi
call   1040 <mysql_query@plt>
test   %rax,%rax
je     11c2 <unreserveIngred+0x52>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0xea7(%rip),%rsi
xor    %eax,%eax
call   1060 <syslog@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x158,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %r12,%rdi
call   1090 <mysql_store_result@plt>
test   %rax,%rax
je     133d <unreserveIngred+0x1cd>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <mysql_num_rows@plt>
test   %eax,%eax
js     1352 <unreserveIngred+0x1e2>
cmp    $0x1,%eax
jne    1370 <unreserveIngred+0x200>
mov    %rbx,%rdi
call   1050 <mysql_fetch_row@plt>
mov    %rax,%r15
mov    (%rax),%edi
call   1030 <atof@plt>
movss  %xmm0,0x8(%rsp)
mov    (%r14),%edi
call   1030 <atof@plt>
addss  0x8(%rsp),%xmm0
movss  %xmm0,0x1c(%rsp)
mov    0x4(%r15),%edi
call   1030 <atof@plt>
movss  %xmm0,0x8(%rsp)
mov    0x4(%r14),%edi
call   1030 <atof@plt>
movss  0x8(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
mov    0x8(%r15),%edi
call   1030 <atof@plt>
movss  %xmm0,0x14(%rsp)
mov    0x8(%r14),%edi
call   1030 <atof@plt>
movss  0x14(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x14(%rsp)
mov    0xc(%r15),%edi
call   1030 <atof@plt>
movss  %xmm0,0x10(%rsp)
mov    0xc(%r14),%edi
call   1030 <atof@plt>
movss  0x10(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x10(%rsp)
mov    0x10(%r15),%edi
call   1030 <atof@plt>
movss  %xmm0,0xc(%rsp)
mov    0x10(%r14),%edi
call   1030 <atof@plt>
movss  0xc(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
mov    0x14(%r15),%edi
call   1030 <atof@plt>
movss  %xmm0,0x18(%rsp)
mov    0x14(%r14),%edi
call   1030 <atof@plt>
movss  0x18(%rsp),%xmm5
addss  %xmm0,%xmm5
lea    0xe12(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
movss  0x1c(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
movss  0x14(%rsp),%xmm2
movss  0x10(%rsp),%xmm3
movss  0xc(%rsp),%xmm4
call   1070 <sprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <mysql_query@plt>
test   %rax,%rax
je     1385 <unreserveIngred+0x215>
mov    0x2cba(%rip),%rax
mov    (%rax),%edi
lea    0xe25(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <syslog@plt>
jmp    11b1 <unreserveIngred+0x41>
mov    0x2c9c(%rip),%rax
mov    (%rax),%edi
lea    0xd31(%rip),%rsi
jmp    11a5 <unreserveIngred+0x35>
mov    0x2c87(%rip),%rcx
mov    (%rcx),%edi
lea    0xd42(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <syslog@plt>
jmp    11ac <unreserveIngred+0x3c>
mov    0x2c69(%rip),%rax
mov    (%rax),%edi
lea    0xd46(%rip),%rsi
jmp    11a5 <unreserveIngred+0x35>
xor    %ebx,%ebx
jmp    11b1 <unreserveIngred+0x41>

LLVM IR (-O0):
@.str = [76 x i8] c"SELECT ing0, ing1, ing2, ing3, ing4, ing5 FROM orderTable WHERE orderID=\220\22\00"
@LOG_INFO = global i32 0
@.str.1 = [50 x i8] c"ERROR: Unable to query SQL to find expired orders\00"
@.str.2 = [38 x i8] c"ERROR: Unable to get expired results.\00"
@.str.3 = [34 x i8] c"Error: Invalid number of rows: %d\00"
@.str.4 = [48 x i8] c"Error: Too many ingredient level rows returned.\00"
@.str.5 = [94 x i8] c"UPDATE orderTable SET ing0=%f, ing1=%f, ing2=%f, ing3=%f, ing4=%f, ing5=%f WHERE orderID=\220\22\00"
@.str.6 = [34 x i8] c"Error when updating Ingred values\00"
define i32 @unreserveIngred(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca [6 x float]
%11 = alloca [6 x float]
%12 = alloca i8*
%13 = alloca [300 x i8]
store i32* %0, i32** %4
store i32* %1, i32** %5
store i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0), i8** %12
%14 = load i32*, i32** %4
%15 = load i8*, i8** %12
%16 = call i64 @mysql_query(i32* %14, i8* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load i32, i32* @LOG_INFO
%20 = call i32 (i32, i8*, ...) @syslog(i32 %19, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %105
21: ; preds = %2
%22 = load i32*, i32** %4
%23 = call i32* @mysql_store_result(i32* %22)
store i32* %23, i32** %7
%24 = load i32*, i32** %7
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load i32, i32* @LOG_INFO
%28 = call i32 (i32, i8*, ...) @syslog(i32 %27, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %105
29: ; preds = %21
%30 = load i32*, i32** %7
%31 = call i32 @mysql_num_rows(i32* %30)
store i32 %31, i32* %8
%32 = load i32, i32* %8
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = load i32, i32* @LOG_INFO
%36 = load i32, i32* %8
%37 = call i32 (i32, i8*, ...) @syslog(i32 %35, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %36)
store i32 1, i32* %3
br label %105
38: ; preds = %29
%39 = load i32, i32* %8
%40 = icmp ne i32 %39, 1
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32, i32* @LOG_INFO
%43 = call i32 (i32, i8*, ...) @syslog(i32 %42, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %105
44: ; preds = %38
br label %45
45: ; preds = %44
%46 = load i32*, i32** %7
%47 = call i32* @mysql_fetch_row(i32* %46)
store i32* %47, i32** %6
store i32 0, i32* %9
br label %48
48: ; preds = %79, %45
%49 = load i32, i32* %9
%50 = icmp slt i32 %49, 6
br i1 %50, label %51, label %82
51: ; preds = %48
%52 = load i32*, i32** %6
%53 = load i32, i32* %9
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i32, i32* %52, i64 %54
%56 = load i32, i32* %55
%57 = call float @atof(i32 %56)
%58 = load i32, i32* %9
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [6 x float], [6 x float]* %10, i64 0, i64 %59
store float %57, float* %60
%61 = load i32*, i32** %5
%62 = load i32, i32* %9
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i32, i32* %61, i64 %63
%65 = load i32, i32* %64
%66 = call float @atof(i32 %65)
%67 = load i32, i32* %9
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [6 x float], [6 x float]* %11, i64 0, i64 %68
store float %66, float* %69
%70 = load i32, i32* %9
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [6 x float], [6 x float]* %11, i64 0, i64 %71
%73 = load float, float* %72
%74 = load i32, i32* %9
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [6 x float], [6 x float]* %10, i64 0, i64 %75
%77 = load float, float* %76
%78 = fadd float %77, %73
store float %78, float* %76
br label %79
79: ; preds = %51
%80 = load i32, i32* %9
%81 = add nsw i32 %80, 1
store i32 %81, i32* %9
br label %48
82: ; preds = %48
%83 = getelementptr inbounds [300 x i8], [300 x i8]* %13, i64 0, i64 0
%84 = getelementptr inbounds [6 x float], [6 x float]* %10, i64 0, i64 0
%85 = load float, float* %84
%86 = getelementptr inbounds [6 x float], [6 x float]* %10, i64 0, i64 1
%87 = load float, float* %86
%88 = getelementptr inbounds [6 x float], [6 x float]* %10, i64 0, i64 2
%89 = load float, float* %88
%90 = getelementptr inbounds [6 x float], [6 x float]* %10, i64 0, i64 3
%91 = load float, float* %90
%92 = getelementptr inbounds [6 x float], [6 x float]* %10, i64 0, i64 4
%93 = load float, float* %92
%94 = getelementptr inbounds [6 x float], [6 x float]* %10, i64 0, i64 5
%95 = load float, float* %94
%96 = call i32 @sprintf(i8* %83, i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.5, i64 0, i64 0), float %85, float %87, float %89, float %91, float %93, float %95)
%97 = load i32*, i32** %4
%98 = getelementptr inbounds [300 x i8], [300 x i8]* %13, i64 0, i64 0
%99 = call i64 @mysql_query(i32* %97, i8* %98)
%100 = icmp ne i64 %99, 0
br i1 %100, label %101, label %104
101: ; preds = %82
%102 = load i32, i32* @LOG_INFO
%103 = call i32 (i32, i8*, ...) @syslog(i32 %102, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
br label %104
104: ; preds = %101, %82
store i32 0, i32* %3
br label %105
105: ; preds = %104, %41, %34, %26, %18
%106 = load i32, i32* %3
ret i32 %106
}

LLVM IR (-O2):
@.str = [76 x i8] c"SELECT ing0, ing1, ing2, ing3, ing4, ing5 FROM orderTable WHERE orderID=\220\22\00"
@LOG_INFO = global i32 0
@.str.1 = [50 x i8] c"ERROR: Unable to query SQL to find expired orders\00"
@.str.2 = [38 x i8] c"ERROR: Unable to get expired results.\00"
@.str.3 = [34 x i8] c"Error: Invalid number of rows: %d\00"
@.str.4 = [48 x i8] c"Error: Too many ingredient level rows returned.\00"
@.str.5 = [94 x i8] c"UPDATE orderTable SET ing0=%f, ing1=%f, ing2=%f, ing3=%f, ing4=%f, ing5=%f WHERE orderID=\220\22\00"
@.str.6 = [34 x i8] c"Error when updating Ingred values\00"
define i32 @unreserveIngred(i32* %0, i32* nocapture %1) {
%3 = alloca [300 x i8]
%4 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @mysql_query(i32* %0, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load i32, i32* @LOG_INFO
%9 = tail call i32 (i32, i8*, ...) @syslog(i32 %8, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
br label %75
10: ; preds = %2
%11 = tail call i32* @mysql_store_result(i32* %0)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* @LOG_INFO
%15 = tail call i32 (i32, i8*, ...) @syslog(i32 %14, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
br label %75
16: ; preds = %10
%17 = tail call i32 @mysql_num_rows(i32* %11)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* @LOG_INFO
%21 = tail call i32 (i32, i8*, ...) @syslog(i32 %20, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %17)
br label %75
22: ; preds = %16
%23 = icmp eq i32 %17, 1
br i1 %23, label %27, label %24
24: ; preds = %22
%25 = load i32, i32* @LOG_INFO
%26 = tail call i32 (i32, i8*, ...) @syslog(i32 %25, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
br label %75
27: ; preds = %22
%28 = tail call i32* @mysql_fetch_row(i32* %11)
%29 = load i32, i32* %28
%30 = tail call float @atof(i32 %29)
%31 = load i32, i32* %1
%32 = tail call float @atof(i32 %31)
%33 = fadd float %30, %32
%34 = getelementptr inbounds i32, i32* %28, i64 1
%35 = load i32, i32* %34
%36 = tail call float @atof(i32 %35)
%37 = getelementptr inbounds i32, i32* %1, i64 1
%38 = load i32, i32* %37
%39 = tail call float @atof(i32 %38)
%40 = fadd float %36, %39
%41 = getelementptr inbounds i32, i32* %28, i64 2
%42 = load i32, i32* %41
%43 = tail call float @atof(i32 %42)
%44 = getelementptr inbounds i32, i32* %1, i64 2
%45 = load i32, i32* %44
%46 = tail call float @atof(i32 %45)
%47 = fadd float %43, %46
%48 = getelementptr inbounds i32, i32* %28, i64 3
%49 = load i32, i32* %48
%50 = tail call float @atof(i32 %49)
%51 = getelementptr inbounds i32, i32* %1, i64 3
%52 = load i32, i32* %51
%53 = tail call float @atof(i32 %52)
%54 = fadd float %50, %53
%55 = getelementptr inbounds i32, i32* %28, i64 4
%56 = load i32, i32* %55
%57 = tail call float @atof(i32 %56)
%58 = getelementptr inbounds i32, i32* %1, i64 4
%59 = load i32, i32* %58
%60 = tail call float @atof(i32 %59)
%61 = fadd float %57, %60
%62 = getelementptr inbounds i32, i32* %28, i64 5
%63 = load i32, i32* %62
%64 = tail call float @atof(i32 %63)
%65 = getelementptr inbounds i32, i32* %1, i64 5
%66 = load i32, i32* %65
%67 = tail call float @atof(i32 %66)
%68 = fadd float %64, %67
%69 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([94 x i8], [94 x i8]* @.str.5, i64 0, i64 0), float %33, float %40, float %47, float %54, float %61, float %68)
%70 = call i64 @mysql_query(i32* %0, i8* %4)
%71 = icmp eq i64 %70, 0
br i1 %71, label %75, label %72
72: ; preds = %27
%73 = load i32, i32* @LOG_INFO
%74 = call i32 (i32, i8*, ...) @syslog(i32 %73, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
br label %75
75: ; preds = %27, %72, %24, %19, %13, %7
%76 = phi i32 [ 1, %7 ], [ 1, %13 ], [ 1, %19 ], [ 1, %24 ], [ 0, %72 ], [ 0, %27 ]
ret i32 %76
}