void notify_seat_change(int seat_occupied) {
  static int seat_state = 0;
  char msg[(64)] = "{ \"SEAT\" : ";
  if (seat_state != seat_occupied) {
    snprintf(msg + strlen(msg), (64), "\"%d\" }", seat_occupied);
    server_send_notification(msg);
    ;
  }
  seat_state = seat_occupied;
}


x86 assembly (clang, -O0):
<notify_seat_change>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xeaa(%rip),%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
mov    0x2ede(%rip),%eax
cmp    -0x4(%rbp),%eax
je     11a8 <notify_seat_change+0x68>
lea    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x58(%rbp),%rdi
add    %rax,%rdi
mov    -0x4(%rbp),%ecx
mov    $0x40,%esi
lea    0xeaa(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x50(%rbp),%rdi
mov    $0x0,%al
call   1060 <server_send_notification@plt>
mov    -0x4(%rbp),%eax
mov    %eax,0x2e93(%rip)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<notify_seat_change>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %edi,%ebx
movaps 0xef0(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe9c(%rip),%xmm0
movaps %xmm0,(%rsp)
cmp    %edi,0x2ece(%rip)
je     119e <notify_seat_change+0x6e>
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    (%rsp,%rax,1),%rdi
lea    0xeba(%rip),%rdx
mov    $0x40,%esi
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <server_send_notification@plt>
mov    %ebx,0x2e98(%rip)
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@notify_seat_change.seat_state = internal global i32 0
@__const.notify_seat_change.msg = [64 x i8] c"{ \22SEAT\22 : \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [7 x i8] c"\22%d\22 }\00"
define void @notify_seat_change(i32 %0) {
%2 = alloca i32
%3 = alloca [64 x i8]
store i32 %0, i32* %2
%4 = bitcast [64 x i8]* %3 to i8*
%5 = load i32, i32* @notify_seat_change.seat_state
%6 = load i32, i32* %2
%7 = icmp ne i32 %5, %6
br i1 %7, label %8, label %17
8: ; preds = %1
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%11 = call i64 @strlen(i8* %10)
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i32, i32* %2
%14 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %12, i64 64, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%16 = call i32 (i8*, ...) bitcast (i32 (...)* @server_send_notification to i32 (i8*, ...)*)(i8* %15)
br label %17
17: ; preds = %8, %1
%18 = load i32, i32* %2
store i32 %18, i32* @notify_seat_change.seat_state
ret void
}

LLVM IR (-O2):
@notify_seat_change.seat_state = internal unnamed_addr global i32 0
@__const.notify_seat_change.msg = [64 x i8] c"{ \22SEAT\22 : \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [7 x i8] c"\22%d\22 }\00"
define void @notify_seat_change(i32 %0) {
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* @notify_seat_change.seat_state
%5 = icmp eq i32 %4, %0
br i1 %5, label %11, label %6
6: ; preds = %1
%7 = call i64 @strlen(i8* %3)
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 %7
%9 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %8, i64 64, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %0)
%10 = call i32 (i8*, ...) bitcast (i32 (...)* @server_send_notification to i32 (i8*, ...)*)(i8* %3)
br label %11
11: ; preds = %6, %1
store i32 %0, i32* @notify_seat_change.seat_state
ret void
}