#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*/ uint32_t;
typedef int /*<<< orphan*/ uint16_t;
struct rbcfg_ctx {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ put_u32(void *, int /*<<< orphan*/);
int rbcfg_find_tag(struct rbcfg_ctx *, int /*<<< orphan*/, int /*<<< orphan*/ *,
                   void **);
int rbcfg_set_u32(struct rbcfg_ctx *ctx, uint16_t id, uint32_t val) {
  void *tag_data;
  uint16_t tag_len;
  int err;
  err = rbcfg_find_tag(ctx, id, &tag_len, &tag_data);
  if (err)
    return err;
  put_u32(tag_data, val);
  return 0;
}


x86 assembly (clang, -O0):
<rbcfg_set_u32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x24(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1030 <rbcfg_find_tag@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     115e <rbcfg_set_u32+0x3e>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1171 <rbcfg_set_u32+0x51>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1040 <put_u32@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rbcfg_set_u32>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
lea    0x14(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1030 <rbcfg_find_tag@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    1149 <rbcfg_set_u32+0x29>
mov    0x8(%rsp),%rdi
mov    %ebx,%esi
call   1040 <put_u32@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.rbcfg_ctx = type { i32 }
define i32 @rbcfg_set_u32(%struct.rbcfg_ctx* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.rbcfg_ctx*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store %struct.rbcfg_ctx* %0, %struct.rbcfg_ctx** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%11 = load %struct.rbcfg_ctx*, %struct.rbcfg_ctx** %5
%12 = load i32, i32* %6
%13 = call i32 @rbcfg_find_tag(%struct.rbcfg_ctx* %11, i32 %12, i32* %9, i8** %8)
store i32 %13, i32* %10
%14 = load i32, i32* %10
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = load i32, i32* %10
store i32 %17, i32* %4
br label %22
18: ; preds = %3
%19 = load i8*, i8** %8
%20 = load i32, i32* %7
%21 = call i32 @put_u32(i8* %19, i32 %20)
store i32 0, i32* %4
br label %22
22: ; preds = %18, %16
%23 = load i32, i32* %4
ret i32 %23
}

LLVM IR (-O2):
%struct.rbcfg_ctx = type { i32 }
define i32 @rbcfg_set_u32(%struct.rbcfg_ctx* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = bitcast i8** %4 to i8*
%7 = bitcast i32* %5 to i8*
%8 = call i32 @rbcfg_find_tag(%struct.rbcfg_ctx* %0, i32 %1, i32* %5, i8** %4)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load i8*, i8** %4
%12 = call i32 @put_u32(i8* %11, i32 %2)
br label %13
13: ; preds = %3, %10
ret i32 %8
}